Trasform one object from array of objects in json to elasticseach

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 => .....
}
}

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

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

thx Badger, I'll try this

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.

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