In the script for the field I need to check if a geo point (lat, lng) in a field on the document is within a poiygon/bounding box that is provided as a parameter to the script.
I have tried to find information on this but have failed to find the solution so far.
Does anyone know if this is possible?
Below is a sample query of what I want to achieve.
Customers have a list of purchases 'Purchases' where each purchase has a type, price and location (geo_point).
I then want to create a sum field of the purchases that match my criteria on type and location (purchase location within a polygon). These will change with each request.
Then I want to filter on that summary field.
So far I can create the summary field and only summarize purchases matching types I provide but I need to match them on location as well. The second condition in the script below is completely made up. My question is if that method (polygon contains geo point) exists in painless and if it does, what the syntax looks like?
That's currently not supported, painless does not support spatial relationship methods so you cannot check easily if a geo_point is inside of a polygon. Maybe you might want to open a feature request in the Elasticsearch repository?
Another way to solve the problem might be to map the Purchases as type nested.
Then filter on type and location in a normal nested query.
Then in post_filter summarize the inner_hits in a painless script that also performs the range filtering.
I don't think that inner_hits are available in scripts in post_filter though.
Some way to do this kind of thing would be really nice.
How do I open a feature request?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.