June 2017
Beginner to intermediate
404 pages
8h 22m
English
By default, the buckets are ordered in descending order based on the document count. The buckets with the most documents are shown at the top. You can change the order to be ascending, alphabetical, or even based on the value from sub-aggregation. Doing so will increase the possibility of the error. The top buckets will be the most accurate. If the results are calculated based on a single shard due to the use of routing or on a single shard index, the results are always accurate. The terms aggregation with order is shown here:
POST chapter8/_search { "size": 0, "aggs": { "category_products": { "terms": { "field": "category", "order": { "_term": "asc" } } } } }
In the preceding query, the buckets are ordered alphabetically.
Read now
Unlock full access