Dereference arrays in painless script field

Given following document

    {
        "addresses": [    {"city": "New York"},
                                    {"city": "Brussels" } ]
    }

Is it possible to dereference the first element in the array using a painless script filter? All queries I tried did crash. E.g. I want to create a scripted field firstCity like doc['addresses'][0]['city']

Try this

params['_source']['addresses'][1]['city']

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