Elastic search : Can query include kind of a subquery or subqueries using multiple indices?

  • I have index1 with geo-point data, index2 with polygons. Index2 has multiple polygon rows for given say id value. I would like to find all geo-points from index1 that are inside any of the polygons from index2 having say id=1. Is it possible to do that in a single query?
  • One way, I thought was - combine all polygon rows for each unique id value using multi-polgon(so that it becomes single row for each unique id) during data ingestion itself and then it is easy to do the intersection/within query using 2 indices. But there may be a better way of doing this.. If there is, can you please share that idea? Thanks.

Elasticsearch does not support joins, so that is not possible.

That is as far as I can tell still a join. You might be able to enrich at index time, but I can't see a way to do it in a single query.