# ElasticSearch data structure

**URL:** <https://discuss.elastic.co/t/elasticsearch-data-structure/127685>\
**Category:** Elasticsearch\
**Created:** [April 11, 2018, 5:15pm UTC](https://discuss.elastic.co/t/elasticsearch-data-structure/127685 "2018-04-11T17:15:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![barlacon](https://avatars.discourse-cdn.com/v4/letter/b/58956e/32.png) [@barlacon](https://discuss.elastic.co/u/barlacon)\
**Post date:** [April 11, 2018, 5:15pm UTC](https://discuss.elastic.co/t/elasticsearch-data-structure/127685/1 "2018-04-11T17:15:07Z")

</div>

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"}
                }
            }
        }
    }
}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 9, 2018, 5:15pm UTC](https://discuss.elastic.co/t/elasticsearch-data-structure/127685/2 "2018-05-09T17:15:10Z")

</div>

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