# Es query mapping and agg

**URL:** <https://discuss.elastic.co/t/es-query-mapping-and-agg/236619>\
**Category:** Elasticsearch\
**Created:** [June 11, 2020, 4:55am UTC](https://discuss.elastic.co/t/es-query-mapping-and-agg/236619 "2020-06-11T04:55:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zephery\_Wen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zephery_wen/32/124417_2.png) [@Zephery\_Wen](https://discuss.elastic.co/u/Zephery_Wen)\
**Post date:** [June 11, 2020, 4:55am UTC](https://discuss.elastic.co/t/es-query-mapping-and-agg/236619/1 "2020-06-11T04:55:21Z")

</div>

How to realize agg according to dynamic map's key?

PUT aaa/1

```json
{
  "name": {
    "first": "Alice",
    "1": "John"
  },
  "age": 26,
  "joiningDate": "2015-10-15"
}

```

PUT aaa/2

```json
{
  "name": {
    "second": "Blob",
    "1": "2"
  },
  "age": 26,
  "joiningDate": "2015-10-15"
}

```

Here is the result i expect

```json
{
  "1":["John","2"],
  "first":"Alice",
  "second":"Blob"
}

```

---

<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:** [July 9, 2020, 4:55am UTC](https://discuss.elastic.co/t/es-query-mapping-and-agg/236619/2 "2020-07-09T04:55:24Z")

</div>

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