I'm having issues implementing graduated prices in Elasticsearch.
This is the mapping I use (I can change it, as long as it all stays in the same index):
PUT /sw_shop1_product/_mapping
{
"properties": {
"cs_filter_prices": {
"properties": {
"price": {
"type": "double"
},
"from" : {
"type": "long"
}
},
"type": "nested"
}
}
}
So I'm adding multiple prices per document, I need to be able to filter based on amount and price.
The issue is, how can I get the correct documents based on the amount(highest amount that is lower/equal to input amount, and only that one) then also filter on a price ("lte").
Example with 2 products:
PUT sw_shop1_product/_doc/product_name_1
{
"cs_filter_prices": [
{
"price": 1.50,
"from": 1
},
{
"price": 1.25,
"from": 100
},
{
"price": 1.00,
"from": 200
}
]
}
PUT sw_shop1_product/_doc/product_name_2
{
"cs_filter_prices": [
{
"price": 2.50,
"from": 1
},
{
"price": 2.25,
"from": 100
},
{
"price": 2.00,
"from": 200
}
]
}
When I want to search for amount 125 and price "lte" 2.00, I should only get the document "product_name_1".
I have been banging my head against this issue for a bit of time, and I have no clue how to do this.