Hello, I'd like to limit my query results to the first 500 documents and use the pagination (for instance from=0&size=30).
My use case :
- I want to hide the total of documents
- I don't use yet any relevancy aggs (scoring )
- The results are handle by an API (api-platform with a Paginator).
terminate_after did the trick but it's not the right to do that apparently. I have some wrong results when I sort.
Do you have an advice to handle that ?
Do I have to do it with a size of 500 doc and handle the pagination in my app (php in my case) ?
can you maybe explain what did not work as expected with using from/size even without terminate after? What did not work as expected, and what did you expect?
Thanks for your help
from/size feature allows me to divid results into small parts (30 documents in my case) but I'm not able, in the same time, to limit the whole query to a number (ie : 500).
My query looks like this :
I am not sure I understand.
What do you think you gain when limiting the query to 500? Speed? You still need to sort every hit properly by the sort criteria.
BUT: I'd highly encourage you to upgrade to Elasticsearch 7.6.0, as there is a huge speed up optimization when sorting by dates and numbers. See the release blog post at https://www.elastic.co/blog/elasticsearch-7-6-0-released
Yes I'll do the upgrade
I'm not looking for performance at all but handle pagination with one query.
In a natural form, I would have said
"can you give me the first 500 results that match these criteria by cutting them out from 0 to 29 then from 30 to 60"...
But I must thinking wrong way.
I should rather use a size of 500 and then slice the results within my php application
I do not understand, why you are not using from/size parameters for this.
from: 0, size: 30
from: 30, size: 30
from: 60, size: 30
from: 480, size: 20
in order to retrieve 500 results.
Why does that not work for you? What did I miss in your question?
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.