Search by a particular object of an array

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

You could change the format of your JSON when indexing using a script processor 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!

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.

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

Thanks a need to study some documentation :slight_smile:

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