# How to extract nested json objects in to new fields in kibana

**URL:** https://discuss.elastic.co/t/how-to-extract-nested-json-objects-in-to-new-fields-in-kibana/282626
**Category:** Kibana
**Created:** [August 27, 2021, 4:47am UTC](https://discuss.elastic.co/t/how-to-extract-nested-json-objects-in-to-new-fields-in-kibana/282626 "2021-08-27T04:47:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sandhya1](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@sandhya1](https://discuss.elastic.co/u/sandhya1)
#### Post date: [August 27, 2021, 4:47am UTC](https://discuss.elastic.co/t/how-to-extract-nested-json-objects-in-to-new-fields-in-kibana/282626/1 "2021-08-27T04:47:27Z")

</div>

Hi,  
I have one field which is having nested j son object format, i need to extract into new fields. The field is mapped to the "text" data type and from the below format i need the count of unique first name and need to retrieve all the first name.

{Names:[{“first name”: ”A”,”id”:[{‘first id’:””,”Second id”:}],  
{“first name”:”B”,”id”:[{‘first id’:””,”Second id”:}]}],  
Status:”ABC”}

Please help me out ,how can i able to get the count from nested j son object.

Thanks in Advance,  
Sandhya

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [August 30, 2021, 8:42pm UTC](https://discuss.elastic.co/t/how-to-extract-nested-json-objects-in-to-new-fields-in-kibana/282626/2 "2021-08-30T20:42:50Z")

</div>

Hi, if the data is mapped as text in Elasticsearch, then Kibana will only be able to do text-based operations on it. It sounds like the data should be indexed as data, not text.

Also, the data sample you gave is not parseable as JSON, so it's super hard to make a mental picture of what you are dealing with. I recommend using the formatting tools to format the data snippets into code and provide a structure that is actually parseable JSON or formatted in a way that makes the structure clear.

---

<div class="post-metadata">

### Author: ![ghudgins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ghudgins/32/138532_2.png) [@ghudgins](https://discuss.elastic.co/u/ghudgins)
#### Post date: [August 30, 2021, 9:08pm UTC](https://discuss.elastic.co/t/how-to-extract-nested-json-objects-in-to-new-fields-in-kibana/282626/3 "2021-08-30T21:08:29Z")

</div>

you could maybe try a runtime field for this (if you're in 7.13+ the "add field" button is in the field list in lens & discover)

here's an example that extracts price

```auto
// Flatten a nested field 
// Document looks like:
// {
// "products": [ <-- nested field
// { "title": "Kibana", "price": 42.02 },
// { "title": "Elasticsearch", "price": 22.10 }
// ]
// }

for (def product : params._source.products) {
    emit(product.price);
}

```

---

<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: [September 27, 2021, 9:08pm UTC](https://discuss.elastic.co/t/how-to-extract-nested-json-objects-in-to-new-fields-in-kibana/282626/4 "2021-09-27T21:08:59Z")

</div>

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