Skip to main content
Version: 7.2405.x.x LTS

Paging the results

The Query REST Service returns ten results at once by default. It is possible to override the default by setting the size URL parameter in the HTTP request. However, for large result sets we recommend using paging to get the results.

Paging involves issuing more than one HTTP request, one after another, by means of the from URL parameter in the HTTP request.

This is how it works:

  1. Send a first HTTP request to get the first set of ten results.

    This first request may look like this:

    GET https://<hostname>:<port>/nevisidm/api/query/v1/all?q=test

    And this is the response:

    {
    "response": {
    "totalResults": 88,
    "from": 0,
    "size": 10,
    "hits": [
    ...
    ]
    },
    "messages": {}
    }

    The response.totalResults field indicates that the total number of results is "88". However, the service only returned ten results, as you can see in the size field ("size": 10). Furthermore, the from field shows that the index of the first result is "0" ("from": 0).

  2. Send a second HTTP request to get the next set of results.

    You already received the results with index 0-9. To get the second set of results with index 10-19, add the from URL parameter to the HTTP request. Give it the value "10":

    GET https://<hostname>:<port>/nevisidm/api/query/v1/all?q=test&from=10

    This time the response includes the next ten results ("from": 10):

    {
    "response": {
    "totalResults": 88,
    "from": 10,
    "size": 10,
    "hits": [
    ...
    ]
    },
    "messages": {}
    }
  3. Send a third HTTP request to get the third set of results with index 20-29. Therefore, set the from URL parameter in the HTTP request to "20".

  4. Continue with this technique until you have sent the request for the last page (in the example here, this is the request for the results with index 80-88). After receiving the corresponding response, you have got all results of the query.