How to optimize painless script (Elasticsearch)
There is an index with documents in the form of products. Each product has the price and locations fields. The locations type is nested, and there is an array of location objects inside. Each location has an id and a price. There are about 300000 documents in the index, each document has from 0 to 100 locations. The request may or may not pass the locations parameter. The parameter contains a list of location IDs.
The task is as follows:
Painless doesn’t find document object
I have a simple Elasticsearch query with a custom sort painless script that affects the order of the returned results. However, I noticed that the script doesn’t work as expected for all of the document fields, namely the maps and the nested fields. In order to debug the issue I made a small change to the script (see the image below).
How i can iterate over nested propery in painless elasticsearch script
My document mapping looks like this: