0
外场我有这样的映射:Elasticsearch - 骨料对嵌套场,然后在嵌套
{
"event": {
"properties": {
"visitor": {
"type": "keyword"
},
"location": {
"type": "nested",
"properties": {
"country": {
"type": "keyword"
},
"region": {
"type": "keyword"
},
"city": {
"type": "keyword"
}
}
}
}
}
}
这两个集合工作打算:
{
"size": 0,
"aggs": {
"location": {
"nested": {
"path": "location"
},
"aggs": {
"by_country": {
"terms": {
"field": "location.country"
}
}
}
}
}
}
{
"size": 0,
"aggs": {
"visitor_count": {
"cardinality": {
"field": "visitor"
}
}
}
}
但是当我尝试将它们合并像这样,国家聚合工作正常,但访问者数量都等于0,这是错误的。
{
"size": 0,
"aggs": {
"location": {
"nested": {
"path": "location"
},
"aggs": {
"by_country": {
"terms": {
"field": "location.country"
},
"aggs": {
"visitor_count": {
"cardinality": {
"field": "visitor"
}
}
}
}
}
}
}
}
有人能告诉我如何实现我想要做的事吗? 我想问题是visitor
字段不是嵌套location
字段的一部分,但我找不到解决方法。 (当然,实际映射更复杂,我真的想避免改变它)