How to Paginate Query Results
Important
The procedures in this tutorial might not be sufficient to optimize search query performance for all use cases. To provide feedback on your use case, use the MongoDB Feedback Engine.
Atlas Search queries might return many results. To make navigating results easier, you can either use pagination to divide results into discrete pages or use cursor iteration to view all the results for your query.
The following tutorials take you through the steps for paginating your query results:
The How to Divide Query Results into Discrete Pages tutorial demonstrates how to create an Atlas Search index and paginate the query results using
$skip
and$limit
stages after the$search
stage to divide the results into discrete pages. The tutorial also demonstrates how to useSEARCH_META
Aggregation Variable to return the total number of search results for a query.The How to Iterate Your Cursor to View All Results tutorial demonstrates how to create an index and iterate the cursor until it is exhausted to return all results for a query.