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
).
Constraints
deliveryAreas
must remain a nested field because each delivery area is unique and needs to be queried independently.- We cannot define
segmentedMinimumBasketPrice
astype: nested
insidedeliveryAreas
, 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:
- Keep
deliveryAreas
as a nested field. - Store multiple
segment
+minimumBasketPrice
pairs per delivery area. - Be able to query:
segment = X AND minimumBasketPrice >= or <= Y
. - Avoid unsupported nested-under-nested structure.
- Ensure decent performance and scalability.
Any suggestions for how to model and query this properly in Elasticsearch would be greatly appreciated!