Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I skip records with text search in mongodb

Tags:

mongodb

Following on from a question relating to count in full text searches. Does anyone have a way to skip records returned from a full text search for pagenation purposes?

Example text search -

db.jobs.runCommand("text", {search: "Australia"});

Regards, Sean

like image 929
user1781563 Avatar asked Dec 02 '25 10:12

user1781563


1 Answers

The text command returns “a document that contains a field results that contains an array of highest scoring document, in descending order by score.” Please see the following link on text command details.

http://docs.mongodb.org/manual/reference/command/text/

Both limit and skip will not apply in this case since the returned document is neither a cursor nor an aggregation operation. You will have to improvise limit and skip operations in your application. There are plans to integrate text search into normal MongoDB query stream. You can follow the ticket and vote for the feature under the More Actions button.

https://jira.mongodb.org/browse/SERVER-9063

In addition, the returned document must be able to fit into 16 MB, the BSON document size. Consider using $project and $limit parameters to limit the size of results.

like image 124
Sherry Ger Avatar answered Dec 04 '25 02:12

Sherry Ger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!