Guy Korland
Guy Korland

Reputation: 9568

How to set "skip" on MongoDB text search?

I start using the new MongoDB text search but then I realized it only supports "limit" and there's no "skip". Is there anyway to get a "skip" behavior?

Upvotes: 1

Views: 177

Answers (1)

SCB
SCB

Reputation: 3084

I think as of V2.4.0 you will need to implement this in your application code rather than trying to get Mongo DB to do this as part of a query request. My understanding is that the text search does not return a cursor.

Check the Jira for this issue, https://jira.mongodb.org/browse/SERVER-9063

One solution although not very efficient is to increase the limit size for each new page and then change where you start reading from accordingly.

basic idea below.

request 1
query.limit(20)

request 2

query.limit(40)

start reading from the last position +1

Not very elegant or efficient I'm afraid

Upvotes: 1

Related Questions