Hi All,
I have a question about the capabilities of source filtering.
I have documents which represents products. Each document contains a set product properties and a set of product prices, one price for each country. Something like:
"product": {
"name": "ProductA",
"description": "Product A is really cool",
"collection": "cool products",
....
"prices": {
"US":{
"price": 3000,
"formattedPrice": "3,000 $"
},
"DE":{
"price": 2900,
"formattedPrice": "2.900 €"
},
"FR":{
"price": 2850,
"formattedPrice": "2.850 €"
},
"CH":{
"price": 3050,
"formattedPrice": "CHF 3,050"
},
...
}
}
I would like to use source filtering to return all the document fields, except for prices. For Prices I would like to return only the price of a specific country I know at query time.
For instance: if I'm searching in the context of Switzerland I would need something like:
"_source": {
"includes": "<all fields>"
"excludes": "<all prices that are not for Switzerland>"
}
I tried with "excludes": "prices.~CH", which doesn't work.
The only solution I could find was to add in the excludes clause all the prices that I don't want. e.g.
"_source": {
"includes": "*"
"excludes": ["prices.US", "prices.DE", "prices.FR", ..."]
}
The problem is that the list of countries for which I have a price is long, and can be different from product to product.
Is there a better way to address this requirement?
Thanks in advance,
Francisco