Hey everyone, 

These aggregations are working out great, but I need to return more than 
one value in the bucket so we can use them in our API. The basic idea is 
that we aggregate all of the category id's, but we also want the 
category_name to be included in that same bucket for ease of use.


*Mapping:*
"categories" : {
"properties" : {
"category_name" : {
"analyzer" : "keyword",
"type" : "string"
},
"category_id" : {
"type" : "integer"
},
"parent_id" : {
"type" : "integer"
}
}
}

*Aggs:*
aggs: {
          categories: {
            terms: {
              size: 130,
              field: "categories.category_id"
            }
          },


*Returns (actual):*

"category_stats": [
    {
      "category_id": 58,
      "offer_count": 48885
    },
    {
      "category_id": 1008,
      "offer_count": 44530
    },

    ...



*Returns (desired):*

"category_stats": [
    {
      "category_name": "Car Rental",
      "category_id": 58,
      "offer_count": 48885
    },
    {
      "category_name": "Fast Food",
      "category_id": 1008,
      "offer_count": 44530
    },

    ...

-- 
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/055d0c2b-f4ba-455b-883f-587c09b61582%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to