# Using JSON filter to expand the field created by terms aggregation in transform

**URL:** https://discuss.elastic.co/t/using-json-filter-to-expand-the-field-created-by-terms-aggregation-in-transform/315759
**Category:** Kibana
**Tags:** transforms, ingest-pipeline
**Created:** [October 4, 2022, 10:21am UTC](https://discuss.elastic.co/t/using-json-filter-to-expand-the-field-created-by-terms-aggregation-in-transform/315759 "2022-10-04T10:21:03Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Hendrik\_Muhs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendrik_muhs/32/25802_2.png) [@Hendrik\_Muhs](https://discuss.elastic.co/u/Hendrik_Muhs)
#### Post date: [October 4, 2022, 10:36am UTC](https://discuss.elastic.co/t/using-json-filter-to-expand-the-field-created-by-terms-aggregation-in-transform/315759/2 "2022-10-04T10:36:04Z")

</div>

> [@Hemabh\_Ravee\_Fox](#):
>
> But i can't query for the individual terms inside this field

Transform maps a terms aggregation to a `flattened` field. An alternative to your ingest pipeline is to create a different mapping for this field. `flattened` has been chosen, because the terms agg potentially produces a field with lots of different sub-fields. If you don't have a lot of different fields (the default limit is `1000`) I suggest to create mappings for them, e.g. map them as `long`. If you do, you can search and aggregate on these fields. For defining those mappings I suggest to use a [dynamic template](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html).

Another solution to this problem has been discussed recently in [this thread](https://discuss.elastic.co/t/transform-mapping-errors/313382).

---

_[View the full topic](https://discuss.elastic.co/t/using-json-filter-to-expand-the-field-created-by-terms-aggregation-in-transform/315759)._
