doc-exports/docs/css/umn/css_01_0176.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

72 lines
2.5 KiB
HTML

<a name="css_01_0176"></a><a name="css_01_0176"></a>
<h1 class="topictitle1">Low-cardinality and High-cardinality Field Mixing</h1>
<div id="body0000001081766453"><p id="css_01_0176__en-us_topic_0000001223914328_p8060118">In the scenario where low-cardinality and high-cardinality fields are mixed, assume that the following query statement exists:</p>
<pre class="screen" id="css_01_0176__screen13809145017261">POST testindex/_search
{
"size": 0,
"aggs": {
"groupby_region": {
"terms": {
"field": "region"
},
"aggs": {
"groupby_host": {
"terms": {
"field": "host"
},
"aggs": {
"groupby_timestamp": {
"date_histogram": {
"field": "timestamp",
"interval": "day"
},
"aggs": {
"avg_score": {
"avg": {
"field": "score"
}
}
}
}
}
}
}
}
}
}</pre>
<p id="css_01_0176__p1983613473263">Group the low-cardinality fields and create a histogram using the high-cardinality fields. To use the enhanced aggregation for the preceding query, set the parameters as follows:</p>
<div class="note" id="css_01_0176__note1043711062820"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="css_01_0176__ul572020716284"><li id="css_01_0176__li1672019718286">A clustering key is the prefix subset of a sorting key.</li><li id="css_01_0176__li147204710289">High-cardinality fields must be in the sorting key, and high-cardinality fields must follow the last low-cardinality field.</li></ul>
</div></div>
<pre class="screen" id="css_01_0176__screen158931307272">// Configure an index
"settings" : {
"index" : {
"search" : {
"turbo" : {
"enabled" : "true" // Enable optimization
}
},
"sort" : { // Specify a sorting key
"field" : [
"region",
"host",
"timestamp",
"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>