My documents have a nested field. Each child in the nested field has a 'location' property of type 'geo_point.'
My first hurdle was sorting based on the closest child to my query origin, but I figured out two different ways to do that:
- Extracting the geo_points into a property at the document root level, e.g. 'locations': [[175, 25], [122, 36], ...]
- Sorting on the nested children using 'nested_path'
However, in both of these solutions, the query only returns the distance to the nearest point. I'd like to return distance to every point, while sorting on the minimum distance.
I have a sense that I should use script_fields, but I can't find anything in the documentation about how to apply a script field to every child of a nested field.