How in Elasticsearch to limit count result to maximum of 1000?
So, If count have 400 results, then it respond with 400, if count have 1200, it repond with 1000.
How in Elasticsearch to limit count result to maximum of 1000?
So, If count have 400 results, then it respond with 400, if count have 1200, it repond with 1000.
Why do you want to do this?
I mean, can you describe exactly what you are after? Is that for computation purpose?
If so the sampler aggregation
might be what you want.
I need this for pagination, so in our application we only show 5 page indexes (1 2 3 4 5; 4 5 6 7 8), so I need to count from current page how many page are after, but I need to know if there are maximum 2-4 pages, I don't need to know if there are 100 pages after current
According that you have the total number of hits, the size
and from
parameters, I think that you can do all that on client side IMO, no?
Yes I can do this with total number of hits, but total number can 1000000, but I only need to know if after page with index "n" are 3 more pages or not, so I want to limit the count
I'm afraid I don't understand.
May be someone else does.
We need to show a pagination, pagination only show 5 index on page, examples
1 2 3 4 5
3 4 5 6 7
4 5 6 7 8
so when we show page with index 5, we need to show pagination
3 4 5 6 7
2 pages before and 2 pages after
so, when we show page with index 5 we need to know only if page with index 6 and 7 exist
I need to count/check, from offset 50, if there are more 20 elements or less
Knowing the total number of documents that match the query should be enough to compute that, no?
Yes it is enough, but in this case the engine will do unneeded extra work, no?
No. It won't.
Hmm, but it should analyze all documents, even if it will find 20, it will continue to search all documents in order to calculate the count, how it will know that at 20 it must stop?
Is it an issue? What is the response time you have?
At the moment it is not an issue, but I want to prevent it to be an issue.
My advice: Don't try to fix problems that do not exist.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.