[英]Unknown key for a START_OBJECT in a multiple script aggregations elasticsearch
[英]Unknown key for a START_OBJECT in a multiple aggregations elasticsearch
我正在嘗試建立一個查詢,使我可以在單個查詢上進行多個聚合(在同一級別,而不是子聚合)。 這是我發送的請求:
{
"index": "index20",
"type": "arret",
"body": {
"size": 0,
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "anim fore",
"analyzer": "query_analyzer",
"type": "cross_fields",
"fields": [
"doc_id"
],
"operator": "and"
}
}
]
}
},
"aggs": {
"anim_fore": {
"terms": {
"field": "suggest_keywords.autocomplete",
"order": {
"_count": "desc"
},
"include": {
"pattern": "anim.*fore.*"
}
}
},
"fore": {
"terms": {
"field": "suggest_keywords.autocomplete",
"order": {
"_count": "desc"
},
"include": {
"pattern": "fore.*"
}
}
}
}
}
}
但是,執行此查詢時出現以下錯誤:
Error: [parsing_exception] Unknown key for a START_OBJECT in [fore]., with { line=1 & col=1351 }
我一直試圖以多種形式更改此查詢以使其起作用,但我總是會遇到此錯誤。 我覺得這真的很奇怪,因為此查詢似乎與那里指定的格式兼容: ES文檔 。
也許有一些關於術語聚合的特定內容,但是我無法對其進行梳理。
錯誤出在您的include
設置中,應該只是字符串
"aggs": {
"anim_fore": {
"terms": {
"field": "suggest_keywords.autocomplete",
"order": {
"_count": "desc"
},
"include": "anim.*fore.*" <--- here
}
},
"fore": {
"terms": {
"field": "suggest_keywords.autocomplete",
"order": {
"_count": "desc"
},
"include": "fore.*" <--- and here
}
}
}
在doc_id
之后且在must
為must
關閉數組標記后,您must
逗號結尾,查詢應如下所示
"must": [
{
"multi_match": {
"query": "anim fore",
"analyzer": "query_analyzer",
"type": "cross_fields",
"fields": [
"doc_id" // You have trailing comma here
],
"operator": "and"
}
}
] // And here
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.