I have one field in my elastic search which is visibility_boosters which has two properties country_id and booster_rate.
I want to apply multi match query with these two fields (country_id and booster_rate).
country_id is dynamic and Visibility booster criteria are as below :
0 % => 0 | 5 % => +2 | 10 % => +4 | 15 % => +6 | 20 % => +8
Like if visibility booster is 5% then boost will be 2, if visibility booster is 10% then boost will be 4.
If both field matched based on that I want to boost that doc.
I have tried below solution but does not work for me.
My Query :
if ($country && $country != null) {
$params['body']['query']['bool']['should'][] = [
"bool" => [
"must" => [
[ "match" => [ "visibility_boosters.country_id" => $country->id ] ],
[ "match" => [ "visibility_boosters.booster_rate" => 5 ] ],
],
"boost" => 2.0
]
];
$params['body']['query']['bool']['should'][] = [
"bool" => [
"must" => [
[ "match" => [ "visibility_boosters.country_id" => $country->id ] ],
[ "match" => [ "visibility_boosters.booster_rate" => 10 ] ],
],
"boost" => 4.0
]
];
$params['body']['query']['bool']['should'][] = [
"bool" => [
"must" => [
[ "match" => [ "visibility_boosters.country_id" => $country->id ] ],
[ "match" => [ "visibility_boosters.booster_rate" => 15 ] ],
],
"boost" => 6.0
]
];
$params['body']['query']['bool']['should'][] = [
"bool" => [
"must" => [
[ "match" => [ "visibility_boosters.country_id" => $country->id ] ],
[ "match" => [ "visibility_boosters.booster_rate" => 20 ] ],
],
"boost" => 8.0
]
];
}
These query applies to only one match query, if one query match then it is boosting the doc. I want that if both condition matched then based on visibility criteria boost that doc.