doc-exports/docs/css/umn/css_01_0174.html
Wuwan, Qi 050b395397 CSS UMN 23.2.1 20230926
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>
2024-01-10 14:23:15 +00:00

63 lines
2.1 KiB
HTML

<a name="css_01_0174"></a><a name="css_01_0174"></a>
<h1 class="topictitle1">Grouping and Aggregation of Low-cardinality Fields</h1>
<div id="body0000001081675855"><p id="css_01_0174__en-us_topic_0000001223594380_p8060118">Low-cardinality fields have high data clustering performance when being sorted, which facilitates vectorized optimization. Assume that the following query statement exists:</p>
<pre class="screen" id="css_01_0174__screen3319724112017">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"
}
}
}
}
}
}
}
}</pre>
<p id="css_01_0174__p837072313217">Assume that the <strong id="css_01_0174__b1021715351589">region</strong> and <strong id="css_01_0174__b72176354812">host</strong> are low-cardinality fields. To use the enhanced aggregation, set the parameters as follows:</p>
<div class="note" id="css_01_0174__note326443032220"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="css_01_0174__p4264830122217">The clustering key must be a prefix subset of the sorting key.</p>
</div></div>
<pre class="screen" id="css_01_0174__screen4220515220">// 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"
]
}
}
}</pre>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="css_01_0172.html">Enhanced Aggregation</a></div>
</div>
</div>