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