This worked. Query look something like this:

{
   "query":{
    "match_all":{}
   },     
   "aggs": {
      "categories": {
         "nested": {
            "path": "categories"
         },
         "aggs": {
            "key": {
               "terms": {
                  "field": "categories.key",
   "include" : "f.*"
               },
               "aggs": {
                  "value": {
                     "terms": {
                        "field": "categories.value"
                     }
                  }
               }
            }
         }
      }
   }
}


It is nested query with bucketing by categories.key and then aggregating 
by categories.value. For this to work, categories field has to have "type": 
"nested" in mapping.json:

"categories": {
            "type": "nested",
            "properties": {
              "key": {
                "type": "string"
              },
              "value": {
                "type": "string"
              }
            }
          } 


-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/db6acc38-10dd-4ae1-9d9e-2a312d77f742%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to