Introduction

When you execute a search with the find() function, it returns a Promise that resolves to a WixSearchResult object. This object contains the documents that match the search, faceting and paging information, and functions for paging through the search results.

Did this help?

currentPage


currentPagenumberRead-only

Returns the index of the current results page number.

The currentPage is a zero-based index of the current page of results.

The page size is defined by the limit() function, can be retrieved using the pageSize property. You navigate through pages using the prev() and next() functions.

The currentPage property returns undefined if the search returned no results.

JavaScript
let resultPage = results.currentPage; // 0
Did this help?

documents


documentsArray<Document>Read-only

Returns the documents that match the search.

The current page of documents retrieved by the search.

The properties included in the search result documents array depend on the documentType specified for the search. If the documentType is set to Site/Pages, only the default document properties listed below are returned.

If the documentType is set to a specific Wix app collection (such as "Stores/Products"), the returned search result documents contain additional fields. The fields included in the returned documents are different for each documentType. To view the search schema for each document type, see the following articles:

The search result page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

When no documents match the search, the documents array is empty.

JavaScript
let documents = results.documents; /** * [ * { * "_id": "msr9v", * "url": "/about", * "documentType" "Site/Pages", * "image": "wix:image://v1/45...bba2~mv2.jpg#originWidth=750&originHeight=750", * "title": "The Leader in Website Creation", * "description": "Create your own professional web presence—exactly the way you want. Our powerful..." * }, * ... * ] */
Did this help?

facets


facetsArray<FacetResult>Read-only

Returns the facet results retrieved by the search.

The facet results provide grouping information for documents returned by the search, based on the requested facets.

Facet results are structured as follows:

Each facet specified in the facets() function returns a single facet result. Each facet result includes a facet group containing the name of the specified facet and an array of facets listing the number of documents matching each facet value.

The following example shows the facet results for a store product search for which collections and onSale were specified as facets:

"facets": [ { "facet": "collections", "facets": [ { "facetValue": "Boots", "count": 13 }, { "facetValue": "Running Shoes", "count": 22 }, { "facetValue": "Sandals", "count": 18 } ] }, { "facet": "onSale", "facets": [ { "facetValue": "true", "count": 17 }, { "facetValue": "false", "count": 36 } ] } ]

When no facets are specified in the facets() function, the returned facets array is empty.

JavaScript
import wixSearch from "wix-search"; // ... wixSearch .search() .documentType("Stores/Products") .facets("collections", "inStock") .find() .then((results) => { const facets = results.facets; }) .catch((error) => { console.log(error); }); /* Example facets array * * [ * { * "facet": "collections", * "facets": * [ * { * "facetValue": "Winter", * "count": 29 * }, * { * "facetValue": "Spring", * "count": 17 * }, * { * "facetValue": "Summer", * "count": 36 * } * ] * }, * { * "facet": "inStock", * "facets": * [ * { * "facetValue": "true", * "count": 67 * }, * { * "facetValue": "false", * "count": 15 * } * ] * } * ] * */
Did this help?

length


lengthnumberRead-only

Returns the number of documents in the current results page.

The length is the number of documents in the current page. This may be different than the pageSize, which is defined by the limit() function.

You navigate through pages using the prev() and next() functions.

JavaScript
let resultLength = results.length; // 20
Did this help?

pageSize


pageSizenumberRead-only

Returns the search page size.

The page size is defined by the limit() function, can be retrieved using the pageSize property. You navigate through pages using the prev() and next() functions.

JavaScript
let resultPageSize = results.pageSize; // 25
Did this help?