# What is the best practices for index mapping nested under nested

**URL:** <https://discuss.elastic.co/t/what-is-the-best-practices-for-index-mapping-nested-under-nested/379917>\
**Category:** Elasticsearch\
**Created:** [July 8, 2025, 1:38pm UTC](https://discuss.elastic.co/t/what-is-the-best-practices-for-index-mapping-nested-under-nested/379917 "2025-07-08T13:38:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikarahan47](https://avatars.discourse-cdn.com/v4/letter/i/ac8455/32.png) [@ikarahan47](https://discuss.elastic.co/u/ikarahan47)\
**Post date:** [July 8, 2025, 1:38pm UTC](https://discuss.elastic.co/t/what-is-the-best-practices-for-index-mapping-nested-under-nested/379917/1 "2025-07-08T13:38:36Z")

</div>

Hi everyone,  
We want to index delivery area-specific data in Elasticsearch. Each `deliveryArea` is a **unique object** , and inside it we need to store segment-specific data like `minimumBasketPrice` per segment (e.g., "a", "b", "c"). Here's the structure we would like:

```auto
{
  "deliveryAreas": [
    {
      "segmentedMinimumBasketPrice": [
        { "segment": "a", "minimumBasketPrice": 15 },
        { "segment": "b", "minimumBasketPrice": 20 }
      ]
    }
  ]
}

```

To query this data, we need to filter by `segment` and compare `minimumBasketPrice` values using range queries (e.g., `segment = a AND minimumBasketPrice <= 15`).

* * *

### ⚠ **Constraints**

- `deliveryAreas` must remain a **nested** field because each delivery area is unique and needs to be queried independently.
- We **cannot** define `segmentedMinimumBasketPrice` as `type: nested` inside `deliveryAreas`, as **Elasticsearch does not support nested fields inside other nested fields** (nested-under-nested is not officially supported).
- We still need to **accurately pair segment with minimumBasketPrice** inside each `deliveryArea`, and be able to filter using nested queries.

* * *

### ❓ **What We Need Help With**

We’re looking for the best way to model this data structure while satisfying the following:

1. Keep `deliveryAreas` as a nested field.
2. Store multiple `segment` + `minimumBasketPrice` pairs per delivery area.
3. Be able to query: `segment = X AND minimumBasketPrice >= or <= Y`.
4. Avoid unsupported nested-under-nested structure.
5. Ensure decent performance and scalability.

Any suggestions for how to model and query this properly in Elasticsearch would be greatly appreciated!
