Diane Duquesne
Diane Duquesne

Reputation: 514

How to fetch pages of results with an ElasticSearch?

I am working on getting datas from an API with ElasticSearch and have some issues with fetching all the results.

I tried to use the from parameter without success, it even has a strange behaviour.

For example I have one request rendering me 15 results, here are the different number of results depending on the value of the parameter from :

from=9 - gives me 1 result
from=10 - gives me 7 results
from=11 - gives me 2 results
from=12 - gives me 5 results
from=13 - gives me 9 results

Thanks for helping !

Upvotes: 4

Views: 533

Answers (1)

jitendra
jitendra

Reputation: 195

It's quite simple from https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html:

{ "from" : 0, "size" : 10, "query" : { "term" : { "user" : "kimchy" } } }

from is from where to start the result ie. offset (This is applied after all your filters etc. in query). And size is max number of document to be return.

You should post your query also if issue persists.

Upvotes: 2

Related Questions