2

In Mongo shell I use:

db.org_all.find({$text:{$search:"school"}}).limit(1000)

How to use .limit() in RESTHeart API?

/publicdb/org_all?find={$text:{$search:"school"}}&limit=10 doesn’t work.

dakab
  • 5,379
  • 9
  • 43
  • 67

1 Answers1

3

In RESTHeart you specify the page and pagesize query parameters.

In your case, you need to specify pagesize=10 (not limit) the request should be:

GET /publicdb/org_all?filter={"$text":{"$search":"school"}}&pagesize=10

You'll find more information on restheart documentation query documents section, including the query parameters filter, page, pagesize and keys (projections)

Andrea Di Cesare
  • 1,125
  • 6
  • 11
  • If i use `/publicdb/org_all?filter={"$text":{"$search":"school"}}&pagesize=10&page=3`, i have error massage _ERROR org.restheart.handlers.ErrorHandler - Error handling the request com.mongodb.MongoException: Executor error: OperationFailed Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit._ If i use command `db.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes: 135544320})` query work, but wery slow - 3900ms (300000 documments, >50000 result for query "school"). Maybe i can use limit in "Application Logic" ? – Anton Shishkin Nov 24 '15 at 05:29
  • try to create a text index on *school* property; you can do it with RESTHeart using the request `http -a a:a PUT 127.0.0.1:8080/publicdb/org_all/_indexes/ti keys:='{"schoold": "text"}'`. Aslo see [mongodb text index docs](https://docs.mongodb.org/manual/core/index-text/) – Andrea Di Cesare Nov 24 '15 at 10:17