【发布时间】:2015-11-18 19:45:34
【问题描述】:
我在 ES 中的索引 test_agg 上存储了以下类型的嵌套数据。
{
"Date": "2015-10-21",
"Domain": "abc.com",
"Processed_at": "10/23/2015 9:47",
"Events": [
{
"Name": "visit",
"Count": "188",
"Value_Aggregations": [
{
"Value": "red",
"Count": "100"
}
]
},
{
"Name": "order_created",
"Count": "159",
"Value_Aggregations": [
{
"Value": "$125",
"Count": "50"
}
]
},
]
}
嵌套项的映射是
curl -XPOST localhost:9200/test_agg/nested_evt/_mapping -d '{
"nested_evt":{
"properties":{
"Events": {
"type": "nested"
}
}
}
}'
我正在尝试使用以下查询获取“Events.Count”和“Events.Value_Aggregations.Count”,其中 Events.Name='Visit'
{
"fields" : ["Events.Count","Events.Value_Aggregations.Count"]
"query": {
"filtered": {
"query": {
"match": { "Domain": "abc.com" }
},
"filter": {
"nested": {
"path": "Events",
"query": {
"match": { "Events.Name": "visit" }
},
}
}
}
}
}
而不是产生单个值
Events.Count=[188] Events.Value_Aggregations.Count=[100]
它给了
Events.Count=[188,159] Events.Value_Aggregations.Count=[100,50]
获得所需输出的确切查询结构是什么?
【问题讨论】:
标签: elasticsearch