I am struggling with this for a time. The scenario is the following: I have an elasticsearch index which has products and each product has a store. The store has fields that store its latitude, longitude and the max distance which it delivers (basically, it's the max radius). I also have the user's location (lat and lon).
What I need is this: user searches for a product. I need to show him only the ones that are in stores that deliveries to his region.
More logically: get every product which lat and lon of user are inside the store's max distance of delivery.
I don't know if it is possible... I achieved a very similar scenario, using geo distance query. The problem with it is that user needs to select the distance (max radius) that he wants.
Contextualizing: It would be very strange to search for a product, and it returns from a store that doesn't delivery to user.
This is the structure of documents which I am saving at the index.
{
"id" : 425406,
"codAlfa" : "1",
"description" : "Product",
"store" : {
"id" : 1,
"name" : "testeapi",
"lat": 51.489761,
"lon": 0.122890,
"maxDeliveryDistance" : 20
}
}