Aggregations key with sub array


(Frank Heinen) #1

I'll do my best to explain my challenge as clear as possible.

We use Elastic for a store of products. And we have an aggregation (filter) with brand names. Now we'd like to use a brand_id and a brand_name for the filter. Why? Because the encoding of many brand names like L'Oréal. The brand_id will be used on the background to handle the filtering.

At the moment I get the brand_name with my aggregation but I can't seem to find a solution to get the brand_id and brand_name in the aggregation.
Current situation:

 [1] => Array
        (
            [key] => loreal
            [doc_count] => 39
        )

Desired situation (or something workable in this direction):

 [1] => Array
        (
            [key] => loreal
            [name] => L'Oréal
            [doc_count] => 39
        )

Anyone any ideas if this is possible? And how to handle this?