1
我有一個文檔集合,它們都包含具有重要數據的嵌套對象數組。我想要對這些進行聚合,這會返回該組中的第一個文檔,最後一個文檔以及所有嵌套對象。除了嵌套對象外,我可以實現該列表中的所有內容。在聚合中使用inner_hits
映射:
"instances": {
"properties": {
"aggField": {
"type": "string",
"index": "not_analyzed"
},
"id": {
"type": "integer"
},
"nestedObjs": {
"type": "nested",
"properties": {
"key": {
"type": "string",
"index": "not_analyzed"
},
"value": {
"type": "integer"
}
}
},
"timestamp": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
查詢:
{
"size" : 0,
"aggs" : {
"agg-buckets" : {
"terms" : {
"field" : "aggField",
"size" : 10
},
"aggs": {
"last-report": {
"top_hits": {
"sort": [
{
"timestamp": {
"order": "desc"
}
}
],
"size": 1
}
},
"first-report": {
"top_hits": {
"sort": [
{
"timestamp": {
"order": "asc"
}
}
],
"size": 1
}
},
"nested-objs": {
"nested": {
"path": "nestedObjs",
"inner_hits": {}
}
}
}
}
}
但這失敗:
解析失敗[在意外標記START_OBJECT [嵌套的OBJ]]
如果我刪除了「inner_hits」字段,它工作正常。但它只是給我的文件數量,而不是文件本身。
我在做什麼錯?
E:我使用的是ES版本1.7.1
您正在使用哪個版本的ES? – Val
@Val版本1.7.1 – voiceofthemany
你有沒有想過這個?我與Elastic 1.7.x有完全相同的問題。 –