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

48 lines
1.7 KiB
HTML

<a name="css_01_0175"></a><a name="css_01_0175"></a>
<h1 class="topictitle1">High-cardinality Field Histogram Aggregation</h1>
<div id="body0000001081905261"><p id="css_01_0175__p16687121514217">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:</p>
<pre class="screen" id="css_01_0175__screen39844394244">POST testindex/_search?pretty
{
"size": 0,
"aggs": {
"avg_score": {
"avg": {
"field": "score"
},
"aggs": {
"groupbytime": {
"date_histogram": {
"field": "timestamp",
"calendar_interval": "day"
}
}
}
}
}
}</pre>
<p id="css_01_0175__en-us_topic_0000001268394293_p8060118">This query groups the field <strong id="css_01_0175__b1693212561881">timestamp</strong> using a histogram and calculates the average score. <strong id="css_01_0175__b13636195920">timestamp</strong> is a typical high-cardinality field. To use the enhanced aggregation for the preceding query, set parameters as follows:</p>
<pre class="screen" id="css_01_0175__screen95703147257">// Configure an index
"settings" : {
"index" : {
"search" : {
"turbo" : {
"enabled" : "true" // Enable optimization
}
},
"sort" : { // Specify a sorting key
"field" : [
"timestamp"
]
}
}
}
</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>