# Trasform one object from array of objects in json to elasticseach

**URL:** <https://discuss.elastic.co/t/trasform-one-object-from-array-of-objects-in-json-to-elasticseach/202334>\
**Category:** Logstash\
**Created:** [October 4, 2019, 11:28am UTC](https://discuss.elastic.co/t/trasform-one-object-from-array-of-objects-in-json-to-elasticseach/202334 "2019-10-04T11:28:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![namali](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@namali](https://discuss.elastic.co/u/namali)\
**Post date:** [October 4, 2019, 11:28am UTC](https://discuss.elastic.co/t/trasform-one-object-from-array-of-objects-in-json-to-elasticseach/202334/1 "2019-10-04T11:28:49Z")

</div>

wanted to transfer only selected filed from a json file. and one field has array of objects and from that wanted to take only one object

hotel.json

count:25000  
results:  
hotelcode:h001  
hotelname: Pearl City Hotel  
city: CMB  
image: [{cat:1,original:hoo1\_1.jpg},  
{cat:1,original:hoo1\_2.jpg},  
{cat:2,original:hoo1\_3.jpg},  
{cat:3,original:hoo1\_4.jpg}]  
year\_build:null  
description:null

want to take only one original from multiple original object

mutate {  
add\_field =\> {  
hotelcode =\> "%{[results][hotelcode]}"  
hotelname =\> "%{[results][hotelname]}"  
city =\> "%{[results][city]}"  
image =\> .....  
}  
}

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [October 4, 2019, 1:26pm UTC](https://discuss.elastic.co/t/trasform-one-object-from-array-of-objects-in-json-to-elasticseach/202334/2 "2019-10-04T13:26:47Z")

</div>

If you just want to extract the first entry of the array you can use

```
image => "%{[results][image][0]}"
```

---

<div class="post-metadata">

**Author:** ![namali](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@namali](https://discuss.elastic.co/u/namali)\
**Post date:** [October 4, 2019, 2:18pm UTC](https://discuss.elastic.co/t/trasform-one-object-from-array-of-objects-in-json-to-elasticseach/202334/3 "2019-10-04T14:18:20Z")

</div>

thx Badger, I'll try this

---

<div class="post-metadata">

**Author:** ![namali](https://avatars.discourse-cdn.com/v4/letter/n/a87d85/32.png) [@namali](https://discuss.elastic.co/u/namali)\
**Post date:** [October 7, 2019, 5:36am UTC](https://discuss.elastic.co/t/trasform-one-object-from-array-of-objects-in-json-to-elasticseach/202334/4 "2019-10-07T05:36:00Z")

</div>

Hi Badger,

Thanks for the support. Actually I wanted to get one image from original object from array of amage. and I put image =\> "%{[results][image][0][original]}" and it's work.

---

<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:** [November 4, 2019, 5:36am UTC](https://discuss.elastic.co/t/trasform-one-object-from-array-of-objects-in-json-to-elasticseach/202334/5 "2019-11-04T05:36:01Z")

</div>

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