【发布时间】:2016-02-11 22:27:14
【问题描述】:
我在 elasticsearch 中有以下一组嵌套子聚合(field2 是 field1 的子聚合,field3 是 field2 的子聚合)。 然而事实证明,field3 的术语聚合不会存储没有 field3 的文档。
我的理解是,除了 field3 的术语查询之外,我还必须使用 Missing 子聚合查询来存储这些查询。
但我不确定如何将其添加到下面的查询中以存储两者。
{
"size": 0,
"aggregations": {
"f1": {
"terms": {
"field": "field1",
"size": 0,
"order": {
"_count": "asc"
},
"include": [
"123"
]
},
"aggregations": {
"field2": {
"terms": {
"field": "f2",
"size": 0,
"order": {
"_count": "asc"
},
"include": [
"tr"
]
},
"aggregations": {
"field3": {
"terms": {
"field": "f3",
"order": {
"_count": "asc"
},
"size": 0
},
"aggregations": {
"aggTopHits": {
"top_hits": {
"size": 1
}
}
}
}
}
}
}
}
}
}
【问题讨论】:
标签: elasticsearch elasticsearch-aggregation