Initially, I wondered: are there multiple indices matched in the search, which might include older indices that do not have the correct mapping?
After doing more research, I noticed a few things that apply here:
- The documentation lists the ways to interact with
nested
documents, and it doesn't mention they can be interacted with in a script: https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html#nested-accessing-documents - The documentation states that nested objects are stored as separate documents, but the script query works on single documents at a time
- I found another post with a similar question, and the responder stated:
You can not access the values of all nested objects in a script at query time. Your script query only works on one nested object at a time.