forked from docs/doc-exports
Reviewed-by: Kacur, Michal <michal.kacur@t-systems.com> Co-authored-by: Wuwan, Qi <wuwanqi1@noreply.gitea.eco.tsi-dev.otc-service.com> Co-committed-by: Wuwan, Qi <wuwanqi1@noreply.gitea.eco.tsi-dev.otc-service.com>
1.7 KiB
1.7 KiB
High-cardinality Field Histogram Aggregation
High-cardinality fields are usually used for histogram grouping and aggregation instead of single-point grouping and aggregation. For example, collecting the statistics of logs at a certain period. Assume that the following query statement exists:
POST testindex/_search?pretty { "size": 0, "aggs": { "avg_score": { "avg": { "field": "score" }, "aggs": { "groupbytime": { "date_histogram": { "field": "timestamp", "calendar_interval": "day" } } } } } }
This query groups the field timestamp using a histogram and calculates the average score. timestamp is a typical high-cardinality field. To use the enhanced aggregation for the preceding query, set parameters as follows:
// Configure an index "settings" : { "index" : { "search" : { "turbo" : { "enabled" : "true" // Enable optimization } }, "sort" : { // Specify a sorting key "field" : [ "timestamp" ] } } }
Parent topic: Enhanced Aggregation