[英]Elasticsearch: aggregate nested objects
I have the data in the following structure 我有以下结构的数据
"mappings" : {
"PERSON" : {
"properties" : {
"ADDRESS" : {
"type": "nested",
"properties" : {
"STREET" : {
"type": "nested",
"properties" : {
"street": {
"type": "string"
},
"number": {
"type": "integer"
}
}
},
"CITY" : {
"type": "nested",
"properties" : {
"name": {
"type": "string"
},
"size": {
"type": "integer"
}
}
}
,
"country": {
"type": "string"
}
}
},
"INFORMATION" : {
"type": "nested",
"properties" : {
"age": {
"type": "integer"
},
"sex": {
"type": "string"
}
}
}
"name" : {
"type": "string",
}
}
}
}
I want to aggregate nested object dynamically in form: ["object type": count of records with this type]. 我想以以下形式动态聚合嵌套对象:[“ object type”:具有该类型的记录数]。
eg for the PERSON I want to get something like: 例如,对于PERSON,我想要获得类似的东西:
[ADDRESS: 1000, INFORMATION: 1230] [地址:1000,信息:1230]
and for ADDRESS: 对于地址:
[STREET: 200, CITY: 100] [街道:200,城市:100]
Is it possible? 可能吗?
您可以先根据PERSON或ADDRESS进行过滤,然后使用基数汇总来获取计数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.