Elasticsearch polymerization Aggs Getting Started

Source: Internet
Author: User

Elasticsearch is a powerful open source software that not only retrieves the sort, but also makes more complex operations on the document-aggregation.

1, single-value aggregation

  Sum sum, the DSL reference is as follows:

{  "size": 0,  "Aggs":{    "return_balance":{      "sum": {        "field": "Balance"}}}  }

Returns the sum of balance, where size=0 indicates that there is no need to return the document participating in the query.

Min to find minimum value

{  "size": 0,      "Aggs": {"return_min_balance         "      : {"min": { "Field": "Balance"}}}  }

return results

Max asks for maximum value

{  "size": 0,  "Aggs":          {"return_max_balance": {" Max ": {        " field ":" Balance "   }}}

return Result:

AVG Averaging

{  "size": 0,  "Aggs":      {    "return_avg_balance         ": {"avg": { "Field": "Balance"}}}  }

return Result:

Cardinality for cardinality (example below, find gender cardinality M, F, a total of two)
{  "size": 0,  "Aggs":          {"return_cardinality": {" Cardinality ": {        " field ":" Gender "   }}}

The result is:

2. Multi-value Aggregation

percentiles percent of the request

When viewing official documents, I don't understand, here is an example of your own test, see percentage of salary range by gender (F,M)

{  "size": 0,  "Aggs":      {    "states         ": {"Terms": { "Field": "Gender"      },      "Aggs": {        "banlances": {          "Percentile_ Ranks ": {            " field ":" Balance ",            " values ": [              20000,               40000            ]   }}}}

Results:

Stats statistics

See Statistics of Balance:

{  "size": 0,  "Aggs":      {    "balance_stats         ": {"stats": { "Field": "Balance"}}}  }

return Result:

Extended_stats Extended Statistics
{  "size": 0,  "Aggs":          {"Balance_stats": {" Extended_stats ": {        " field ":" Balance "   }}}

Results:

More complex queries, followed slowly in practice.

Elasticsearch polymerization Aggs Getting Started

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.