# Transform documents to create new fields from aggregated data

**URL:** https://discuss.elastic.co/t/transform-documents-to-create-new-fields-from-aggregated-data/224562
**Category:** Elasticsearch
**Created:** [March 22, 2020, 1:48pm UTC](https://discuss.elastic.co/t/transform-documents-to-create-new-fields-from-aggregated-data/224562 "2020-03-22T13:48:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Anup\_Shirolkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anup_shirolkar/32/64858_2.png) [@Anup\_Shirolkar](https://discuss.elastic.co/u/Anup_Shirolkar)
#### Post date: [March 22, 2020, 1:48pm UTC](https://discuss.elastic.co/t/transform-documents-to-create-new-fields-from-aggregated-data/224562/1 "2020-03-22T13:48:05Z")

</div>

Hi,

I am using the opensource version of elastic and want to transform my data as follows:

The metric data is collected from a Hadoop cluster over JMX interface

```auto
Mapping:
@queue :keyword
@metric_type :keyword
@cluster :keyword
@value :numeric
@timestamp :timestamp

```

```auto
Data: (in the input index)
{@queue: queue1, @metric_type: used_memory, @value: 1024, @cluster: dev }
{@queue: queue1, @metric_type: max_memory, @value: 102400, @cluster: dev}
{@queue: queue2, @metric_type: used_memory, @value: 2048, @cluster: prod}
{@queue: queue2, @metric_type: max_memory, @value: 204800, @cluster: prod}

Result: (in a new index)
{@queue: queue1, @used_memory: 1024, @cluster: dev}
{@queue: queue1, @max_memory: 102400, @cluster: dev}
{@queue: queue2, @used_memory: 2048, @cluster: prod}
{@queue: queue2, @max_memory: 204800, @cluster: prod}

```

Here I want to use distinct values of **@metric\_type** to be my new fields and value for it is the corresponding value from the **@value** field of source index.

I have tried the transform API but I don't think it still supports to create new terms. Or by any other means, it is not possible to achieve this result.

Please let me know if there is a way I can use the transform API for this or any alternate solution.

Thanks.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [March 23, 2020, 10:56am UTC](https://discuss.elastic.co/t/transform-documents-to-create-new-fields-from-aggregated-data/224562/2 "2020-03-23T10:56:44Z")

</div>

Hey,

can you show in more detail what you tried, and what errors you are getting? Which requests are you sending, what the responses are looking like and what you would expect them to be instead.

Otherwise debugging gets crazy hard with only a few bits of information available.

--Alex

---

<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: [April 20, 2020, 10:56am UTC](https://discuss.elastic.co/t/transform-documents-to-create-new-fields-from-aggregated-data/224562/3 "2020-04-20T10:56:55Z")

</div>

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