我正在尝试在ElasticSearch中创建一个查询,该查询将列出具有相应计数的不同user_label.id
:
示例文档看起来像这样:
{
"_index": "labels",
"_type": "users",
"_id": "484",
"_version": 69,
"found": true,
"_source": {
"id": 484,
"is_complete": 1,
"language": "nl",
"user_label": [
{
"guid": {
"163579": {
"order_id": 163579
}
},
"id": "boleto"
}
]
}
}
映射类型为nested
。
"user_label" : {
"type" : "nested",
"properties" : {
"guid" : {},
"id" : {
"type" : "string"
},
"tag" : {
"type" : "string"
}
}
}
我想构建一个像:
这样的表+---------------+-------+
| boleto | 32453 |
| paid | 34345 |
| reminder_sent | 345 |
+---------------+-------+
到目前为止,我还有语言,但需要帮助创建user_label.id
:
{
"size": 0,
"aggs": {
"genders": {
"terms": {
"field": "language"
}
}
}
}
尝试使用"field":"user_label.id"
,但它没有奏效。我尝试使用properties
类型,并且点符号有效,但不能使用类型nested
答案 0 :(得分:0)
所以经过一番挖掘后,这就是结果:
{
"size": 0,
"aggs": {
"user_label": {
"nested": {
"path": "user_label"
},
"aggs": {
"id": {
"terms": {
"field": "user_label.id"
}
}
}
}
}
}