The text search command does not have the skip option, as in MongoDB 2.4, so any page numbering should be implemented in your application code.
If you consider text search behavior (which should return results ranked based on relevance), the skip parameter will still need to cache or calculate the initial results in order to skip.
Efficiency
Regarding efficient pagination in your application, a few suggestions:
- cache initial search results and page size subsection for your rendering application
- use a client-side plugin that presents the results of a single query in a beautifully paginated (for example, using the jQuery DataTables plugin)
The number of results returned by the limit
By default, limit for text search returns no more than 100 results. You can increase the limit, but keep in mind that the overall resulting document should still match the maximum BSON document size supported by your MongoDB server (16 MB, as in MongoDB 2.4). Itβs also worth considering that most users have limited patience when searching for results pages, so if you have several hundred results, itβs better to suggest refining your search criteria.
Other options
If you outgrew the current limitations of MongoDB 2.4 text search (which, by the way, is still considered "experimental"), you can always upgrade to a more fully functional search product, such as ElasticSearch or Apache Lucene . There are ways to transfer MongoDB data updates to external search products, for example, using the ElasticSearch River plugin or Mongo Connector .
source share