forked from laiweijian4/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>
2.1 KiB
2.1 KiB
Grouping and Aggregation of Low-cardinality Fields
Low-cardinality fields have high data clustering performance when being sorted, which facilitates vectorized optimization. Assume that the following query statement exists:
POST testindex/_search { "size": 0, "aggs": { "groupby_region": { "terms": { "field": "region" }, "aggs": { "groupby_host": { "terms": { "field": "host" }, "aggs": { "avg_cpu_usage": { "avg": { "field": "cpu_usage" } } } } } } } }
Assume that the region and host are low-cardinality fields. To use the enhanced aggregation, set the parameters as follows:
// Configure an index "settings" : { "index" : { "search" : { "turbo" : { "enabled" : "true" // Enable optimization } }, "sort" : { // Specify a sorting key "field" : [ "region", "host", "other" ] }, "cluster" : { "field" : [ // Specify a clustering key "region", "host" ] } } }
Parent topic: Enhanced Aggregation