【发布时间】:2015-07-29 13:21:08
【问题描述】:
我的索引文档看起来有点像这样;
- a - Parent doc
\- b - Nested doc (0 to many relation to a)
\- c - Child doc (0 to many relation to a)
\- d - Child doc (0 to many relation to a)
a 和 b 中的信息“从不”更改。 c 和 d 中的信息经常更改,父子关系似乎完美匹配。
在 b 上执行聚合就可以了。使用 c/d 的过滤器/查询也可以正常工作。当我尝试组合“has_child”过滤器 c/d 和 b 的嵌套聚合时,不会返回聚合。在 _hits 正确数量的父项下返回一个文档(总数)。
有没有办法执行这种类型的聚合,或者这是一个限制?
/someindex/a/_search
{
"size": 0,
"filter": {
"has_child": {
"type": "c",
"filter": {
"term": { "someFieldInC": 123}
}
}
}
},
"aggregations" : {
"details": {
"nested": {
"path": "b"
},
"aggregations" : {
"details-filter" : {
"filter" : {
"query" : {
"term": {"b.someFieldInB": 123}
}
},
"aggregations" : {
"some_count" : {
"terms" : {
"field" : "b.someCountFieldInB"
}
}
}
}
}
}
}
}
给予
{
"took":22,
"timed_out":false,
"_shards": {
"total":5,
"successful":5,
"failed":0
},
"hits":{
"total":20134,
"max_score":0.0,
"hits":[]
}
}
【问题讨论】:
标签: elasticsearch