I maintain a mapping on the client side to due the lookups. Thankfully my
taxonomy is static (but somewhat large). There is a PR to do server-side
mappings, but I don't think it would apply to aggregations and is quite old.

An alternative solution would be to create compound values such as
"48885:Car Rental" and decompose the value on the client side, but this
would create a string aggregation, which could have slower performance.

Cheers,

Ivan

On Fri, Oct 24, 2014 at 5:50 PM, Cody Stringham <cs.nega...@gmail.com>
wrote:

> 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 elasticsearch+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/055d0c2b-f4ba-455b-883f-587c09b61582%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/055d0c2b-f4ba-455b-883f-587c09b61582%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQB-Asuq5igGP-mJQ7RGv4t2CjsjryBGSTPDn0EAb-vfZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to