Search...
next( )
Retrieves the next page of search results.
Description
The next()
function retrieves the next page of search 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.
If items are added or removed between calls to next()
, the values returned
by WixSearchResult
may change.
Syntax
function next(): Promise<WixSearchResult>
next Parameters
This function does not take any parameters.
Returns
Fulfilled - A search result object with the next page of search results. Rejected - The errors that caused the rejection.
Return Type:
Promise<WixSearchResult>
Was this helpful?
Get the next page of a search result
Copy Code
1oldResults.next()2 .then( (results) => {3 let newResults = results;4 let documents = newResults.documents;5 let firstDocument = documents[0];6 let facets = results.facets;7 let totalCount = newResults.totalCount;8 let pageSize = newResults.pageSize;9 let currentPage = newResults.currentPage;10 let totalPages = newResults.totalPages;11 let hasNext = newResults.hasNext();12 let hasPrev = newResults.hasPrev();13 let length = newResults.length;14 } )15 .catch( (error) => {16 console.log(error);17 } );
Iterate through all pages of search results
This example demonstrates how to get all search results, bypassing the maximum limit of 1000.
Copy Code
1async function retrieveAllDocuments(phrase){2 let allDocuments = [];34 let results = await wixSearch.search(phrase)5 .limit(1000)6 .find();78 allDocuments.push(results.documents);910 while(results.hasNext()) {11 results = await results.next();12 allDocuments.push(results.documents);13 }1415 return allDocuments;16}