# Search by a particular object of an array

**URL:** <https://discuss.elastic.co/t/search-by-a-particular-object-of-an-array/224005>\
**Category:** Elasticsearch\
**Created:** [March 17, 2020, 10:13pm UTC](https://discuss.elastic.co/t/search-by-a-particular-object-of-an-array/224005 "2020-03-17T22:13:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gborasio](https://avatars.discourse-cdn.com/v4/letter/g/85e7bf/32.png) [@gborasio](https://discuss.elastic.co/u/gborasio)\
**Post date:** [March 17, 2020, 10:13pm UTC](https://discuss.elastic.co/t/search-by-a-particular-object-of-an-array/224005/1 "2020-03-17T22:13:29Z")

</div>

Hi all  
i have a json with this format:  
{

"\_source": {  
"m\_header": {  
"m\_playerCarIndex": 2  
},  
"m\_lapData": [  
{  
"m\_currentLapTime": 1.5848066806793213  
},  
{  
"m\_currentLapTime": 1.6660668067933333  
},  
{  
"m\_currentLapTime": 1.56577806793213  
}  
}

Is it possible to make a search of array in m\_lapdata where the position is m\_playerCarIndex ?

in this case m\_playerCarIndex: 2

the output should be:  
{  
"m\_currentLapTime": 1.6660668067933333  
}

the second element of array.

Thanks a lot

---

<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 18, 2020, 3:15pm UTC](https://discuss.elastic.co/t/search-by-a-particular-object-of-an-array/224005/2 "2020-03-18T15:15:21Z")

</div>

You could change the format of your JSON when indexing using a [script processor](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/script-processor.html) and put that part of the document in a dedicated field or remove the other parts of the array.

Maybe you can add some more context and explain what you are after.

Thanks!

---

<div class="post-metadata">

**Author:** ![gborasio](https://avatars.discourse-cdn.com/v4/letter/g/85e7bf/32.png) [@gborasio](https://discuss.elastic.co/u/gborasio)\
**Post date:** [March 18, 2020, 5:26pm UTC](https://discuss.elastic.co/t/search-by-a-particular-object-of-an-array/224005/3 "2020-03-18T17:26:33Z")

</div>

Thanks a lot  
the problem is that i receive this format of json in Elasticsearch in AWS from a fixed source that i can't change.

---

<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 19, 2020, 2:25pm UTC](https://discuss.elastic.co/t/search-by-a-particular-object-of-an-array/224005/4 "2020-03-19T14:25:25Z")

</div>

Then the script processor sounds like a good way to go to change the format of your JSON to whatever suits you best.

---

<div class="post-metadata">

**Author:** ![gborasio](https://avatars.discourse-cdn.com/v4/letter/g/85e7bf/32.png) [@gborasio](https://discuss.elastic.co/u/gborasio)\
**Post date:** [March 19, 2020, 3:53pm UTC](https://discuss.elastic.co/t/search-by-a-particular-object-of-an-array/224005/5 "2020-03-19T15:53:36Z")

</div>

Thanks a need to study some documentation 🙂

---

<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 16, 2020, 3:53pm UTC](https://discuss.elastic.co/t/search-by-a-particular-object-of-an-array/224005/6 "2020-04-16T15:53:36Z")

</div>

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