# Aggregations key with sub array

**URL:** <https://discuss.elastic.co/t/aggregations-key-with-sub-array/159170>\
**Category:** Elasticsearch\
**Created:** [December 3, 2018, 12:24pm UTC](https://discuss.elastic.co/t/aggregations-key-with-sub-array/159170 "2018-12-03T12:24:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fr4nk](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@Fr4nk](https://discuss.elastic.co/u/Fr4nk)\
**Post date:** [December 3, 2018, 12:24pm UTC](https://discuss.elastic.co/t/aggregations-key-with-sub-array/159170/1 "2018-12-03T12:24:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 31, 2018, 12:24pm UTC](https://discuss.elastic.co/t/aggregations-key-with-sub-array/159170/2 "2018-12-31T12:24:21Z")

</div>

Closed on December 31, 2018, 12:24pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
