Search code examples
restheart

How can I use limit() in RESTHeart API?


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.


Solution

  • 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)