I want to sort the results according to a specific field AND THEN apply the limit filter.
A simple common example would be a SQL query like select name from users order by name limit 100
would have returned the sorted results limited by 100.
I tried the same in Elasticsearch. However, this is not happening. It first applies the limits AND THEN sorts which is giving me undesired results. Can anyone point me what I am doing wrong ? This is the query I am currently using.
{
"sort": [
"full_name"
],
"filter": {
"limit": {
"value": 100
}
}
}
How about using "size" in ElasticSearch? http://www.elasticsearch.org/guide/reference/api/search/from-size.html
The limit filter works on each shard first and then results are merged on one of the nodes. If you have more than one shard, that can produce interesting results. I think, as Gabbar already mentioned, what you are looking for is the "size" parameter.