根據 Elasticsearch檔案,“術語”聚合回傳檔案最多的前十個術語。在我的特殊情況下,我發送了 14 個需要的值。
{
"size": 0,
"aggs": {
"counts": {
"filters": {
"filters": {
"respondents": {
"bool": {
"should": [
{
"terms": {
"my_field": [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14"
],
"size": 20 // this is not working
}
}
]
}
}
}
}
}
}
}
但是其中有4個沒有被退回。如果我將“size”屬性與“my_field”屬性并排添加,則會回傳錯誤:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[terms] query does not support [size]",
"line": 40,
"col": 49
}
],
"type": "parsing_exception",
"reason": "[terms] query does not support [size]",
"line": 40,
"col": 49
},
"status": 400
}
我應該怎么做才能獲得所有 14 個必需的值?
uj5u.com熱心網友回復:
您缺少term聚合并且filter聚合不支持size引數,因為它將在聚合查詢上應用過濾器。
{
"size": 0,
"aggs": {
"counts": {
"filters": {
"filters": {
"respondents": {
"bool": {
"should": [
{
"terms": {
"my_field": [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14"
]
}
}
]
}
}
}
},
"aggs": {
"count": {
"terms": {
"field": "my_field",
"size": 20
}
}
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/473331.html
