"ES" Learning 11-multi-barrel sorting

Source: Internet
Author: User

Sorting of aggregated results

Default: Buckets are sorted according to doc_count descending order.

Built-in sorting:

Set sort by Doc_count ascending: note order,_count

get/cars/transactions/_search{"size":0,    "Aggs" : {        "Colors" : {            "Terms" : {              "Field":"Color",              "Order": {                "_count":"ASC"               }            }        }    }}

Other sort keywords:

_count  Sort by number of documents. Yes terms , histogram and date_histogram effective.

_term  Sorts the alphabetical order of the string values of the word items. Use only terms inside.

_key  Sort by the values of the key values for each bucket (theoretically and _term similarly). Used only in histogram and date_histogram within.

Sort by measure: reference a metric based on the field name

get/cars/transactions/_search{"size":0,    "Aggs" : {        "Colors" : {            "Terms" : {              "Field":"Color",              "Order": {                "Avg_price":"ASC"               }            },            "Aggs": {                "Avg_price": {                    "avg": {"Field":" Price"}                 }            }        }    }}

Multi-value measures use point paths: extended_stats measures to output multiple measures

get/cars/transactions/_search{"size":0,    "Aggs" : {        "Colors" : {            "Terms" : {              "Field":"Color",              "Order": {                "stats.variance":"ASC"               }            },            "Aggs": {                "Stats": {                    "Extended_stats": {"Field":" Price"}                }            }        }    }}

"ES" Learning 11-multi-barrel sorting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.