What is the best practices for index mapping nested under nested

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:

{
  "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).


:warning: 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.

:red_question_mark: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!