I have two indexes, the first one called areas is an index containing of multiple polygons, and second one is an index containing of multiple points indicating the document's lat/lon on earth, the index is called stores.
The problem is that I want to attach areas(polygons) that contain the store's point (lat/lon) inside of them, to the store's document as an embedded object. So I can easily find that a document on stores index has which areas.
In an RDBMS I was able to join this two table and find the needed records, In elasticsearch I can iterate over areas index documents one by one and perform a query to find the stores that fit in the area's polygon, and then perform an update on the store document, as the number of areas are huge, I have to perform over 50,000 queries on elasticsearch.
A good solution would be sending a bulk list of areas with the query and tell elasticsearch to aggregate returning results by them the answer would be something like this:
- Polygon A : [store1, store2, store3],
- Polygon B : [store1, store4, store5]
I didn't find anyway to implement this and I switched back to RDBMS solution which is not very optimized and fast too, but it is faster in design.
Is there anyway to implement this with elasticsearch?