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.
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.
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.
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.
let resultLength = results.length; // 20