Equivalent aggregation query to terms facet

Hi all,

I'm using ES 1.3.2
My document structure

            {
               "mapids" : [mapid1, mapid2,mapid3],
               "rdata" : [ {mapid1: value1}, 

{mapid2:value2},{mapid3:value3} ]
}

We are trying to migrate to the new aggregation framework and I'm trying to
rewrite terms facet which was

{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"terms": {
"mapids": [
0,
77188
],
"execution": "and"
}
}
]
}
}
}
},
"facets": {
"facet1": {
"terms": {
"field": "value"
},
"nested": "rdata",
"facet_filter": {
"term": {
"mapid": "77188"
}
}
}
}
}

Which comes back with the buckets

  • terms: [
    • {
      • term: 10
      • count: 257998
        }
    • ...
    • ....
    • {
      • term: 4
      • count: 28477
        }
        ]

I was trying to rewrite the same query using the aggregation framework but
it comes back Parse Failure [Found two aggregation type definitions in
[rdata]: [filter] and [nested]]]

{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"terms": {
"mapids": [
0,
77188,
77200
],
"execution": "and"
}
}
]
}
}
}
},
"aggs": {
"rdata": {
"filter": {
"term": {
"mapid": "77188"
}
},
"nested": {
"path": "rdata"
},
"aggs": {
"rdata_value": {
"terms": {
"field": "value"
}
}
}
}
}
}

Any help is appreciated
Thanks,
Abhishek

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b7cc4b9b-7767-46b9-a8ab-ff4159b5f502%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I think I figured it out. Each aggs sections sub divides the data. First
aggs buckets all the nested docs. Second aggs restricts the bucket to a
filter. Third aggs run the terms facet on it.

"aggs": {
"foo": {
"nested": {
"path": "rdata"
},
"aggs": {
"bar": {
"filter": {
"term": {
"rdata.mapid": 37
}
},
"aggs": {
"foobar": {
"terms": {
"field": "rdata.value",
"size": 28654,
"order": {
"_count": "desc"
}
}
}
}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e0b49cd3-95c9-4060-851a-739073140ea4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.