Given these documents:
{
"id": "1"
"prices": [
{
"param1": "A",
"param2": "B",
"total": 100
},
{
"param1": "A",
"param2": "C",
"total": 200
}
]
},
{
"id": "2"
"prices": [
{
"param1": "A",
"param2": "B",
"total": 200
},
{
"param1": "A",
"param2": "C",
"total": 300
}
]
},
How can they be filtered by prices range only with their minimum total value ?
Right now my query looks like:
{
...
"query": {
"bool": {
"filter": [
{
"nested": {
"path": "prices",
"query": {
"bool": {
"filter": [
{
"range": {
"prices.total": {
"gte": 200,
"lte": 300
}
}
}
]
}
}
}
}
]
}
}
}
So it returns logically documents 1 and 2 because they both have a price in this range, but I only want to get document 2 because I want the filter logic only to be applied on the minimum price.
I've managed to do this in the ordering with "mode": "min", is there something similar for filtering ?