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
字段的一部分,但我找不到解決方法。 (當然,實際映射更復雜,我真的想避免改變它)