I was trying to use this for my use case. Data fomat of my use case:
"wifi": [
{
"point": 1,
"cha": 14,
"chb": 2
},
{
"point": 2,
"cha": 7,
"chb": 6
}
]
There are many entries like this.
I used nested query to filter only wifi.point value 1:
GET my_index4/_search
{
"_source" : false,
"query": {
"nested": {
"path": "wifi",
"query": {
"bool": {
"must": [
{ "match": { "wifi.point": 1 }}
]
}
},
"inner_hits": {
"highlight": {
}
}
}
}
}
It displays data inside the inner_hits for wifi.point 1.
I need to aggregate this inner_hits data. How can I do this?
Thanks for the information.
I did the aggregation on nested data using this:
GET my_index4/_search
{
"_source": false,
"size": 0,
"aggs": {
"wifi": {
"nested": {
"path": "wifi"
},
"aggs": {
"only_point_name": {
"filter": {
"terms": {
"wifi.point": [
1,2
]
}
},
"aggs": {
"my_agg_1": {
"terms": {
"field": "wifi.point"
},
"aggs": {
"my_agg_2": {
"sum": {
"field": "wifi.chb"
}
}
}
}
}
}
}
}
}
}
It worked fine. Now I need to allow aggregation on data other than the wifi object like "time" and "Id.Mac".
Data format:
{
"time" : 1477373600000,
"Id" : {
"Type" : "NODE",
"Mac" : "00:06:65:2b:d2:40"
},
"wifi" : [{
"point" : 1,
"cha" : 14,
"chb" : 2
}, {
"point" : 2,
"cha" : 7,
"chb" : 6
}
]
}
I tried putting these instead of wifi.point in my above GET query but it didn't generate any output.
How can i do this?
Nested aggregations are only to be used on sections of your document that are defined as "nested" in your mapping definition for the index/doctype. The mapping controls if sub-objects in your JSON docs are mapped to "nested" documents in the index or not.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.