Elastic Search Query Terms and Scoring

I have a query using the following terms:

{ "query": { "bool": { "should": [ { "terms": { "subjects.id": [ 1, 2, 3 ], boost: 3 } }, { "terms": { "qualification_type.id": [ 3, 5 ], boost: 2 } } ] } } 

I work very well, but assigns a better rating to documents that correspond to three topics than to a document corresponding to only one subject.

My question is: is there a way to make the score be the same if there are one or many matches in the subjects?

Thanks in advance!

+6
source share
1 answer

You can convert query terms to filters and wrap them in a permanent counting query . For instance:

 { "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 } }] } } } 
+9
source

All Articles