【发布时间】:2017-02-11 23:38:18
【问题描述】:
弹性搜索 5.2
我想按嵌套对象 state.id = 101 过滤我的项目,并按 state.id 对所有项目进行聚合计数。有状态 ID 为 101、102 和 103 的项目。
聚合计数现在限制为 state.id 101。我希望只获取 state.id = 101 的项目和所有状态 ID 的聚合计数。
我该怎么做?
GET index/items/_search
{
"query": {
"nested" : {
"path" : "state",
"query": {
"bool": {
"filter": {
"term": { "state.id": 101 }
}
}
}
}
},
"aggs" : {
"state" : {
"nested" : {
"path" : "state"
},
"aggs" : {
"count" : { "terms" : { "field" : "state.id" } }
}
}
}
}
【问题讨论】:
标签: elasticsearch