I have a request using terms looking like :
{
"query": {
"bool": {
"should": [
{
"terms": {
"subjects.id": [
1,
2,
3
], boost: 3
}
},
{
"terms": {
"qualification_type.id": [
3,
5
], boost: 2
}
}
]
}
}
I works pretty well but attributes a better score to documents that match three subject than to the document matching only one subject.
My question is : is there a way to force the score to be the same if there is one or many match on the subjects ?
Thanks in advance !
You can convert the terms queries into filters and wrap them into constant score query. For example:
{
"query": {
"bool": {
"should": [{
"constant_score": {
"filter": {
"terms": {
"subjects.id": [1, 2, 3]
}
},
boost: 3
}
}, {
"constant_score": {
"filter": {
"terms": {
"qualification_type.id": [3, 5]
}
},
boost: 2
}
}]
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With