ElasticSearch data structure

I've next data structure

Product:
  name: char

Shop:
  location: geo_point

ShopProduct:
  shop: ForeignKey(Shop)
  product: ForeignKey(Product)
  price: double

What mapping should I use if I need to implement search by Product with pagination an sorting by distance to the shop and product prices?

There are some products which are not being sold by any shops at that moment, but I need to show them in the search results. That is why I think I can't search by shops.

Currently, I have 2 indices by products and by shops. Product has "nested" datatype to shop. Now, if there are any changes in the shop data, I need to rebuild index for the shop and for all his products. Is it any other way to index my data that I can implement required search functionality?

# Current Product Index
"mappings": {
    "product": {
        "properties": {
            "name": {"type": "string"}
            "locations": {
                "type": "nested",
                "properties": {
                    "location": {"type": "geo_point"},
                    "price": {"type": "float"}
                }
            }
        }
    }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.