I'm not really sure how to word my question, but take the following object example:
{
"pricing": [
{"cost": 5000, "style": "fixed"},
{"cost_min": 100, "cost_max": 500, "style": "range"},
{"style": "fixed"}
]
}
What I'm trying to do is (pseudo logic):
Boost score by X IF exists(pricing.cost) OR (exists(pricing.cost_min) AND exists(pricing.cost_max))
This what I currently have:
"bool": {
"should": [
{
"exists": {
"field": "pricing.cost",
"boost": 2
}
},
{
"bool": {
"should": [
{
"exists": {
"field": "pricing.cost_min",
}
},
{
"exists": {
"field": "pricing.cost_max",
}
}
],
"minimum_should_match": 2,
}
}
],
"minimum_should_match": 1,
"boost": 1
}
It works, except that for the example object I gave it boosts "twice", giving a score of 4, but really I want score of 2
By default each clause applies boost = 1. As you want to have boost 2 and not 4 you would have to set boost 0 in pricing.cost_min and pricing.cost_max.