Search code examples
solrsolr-boost

Multiple boost of each matching value in one field


I have the one multiple field, with the following values:

"itm_field_skills":[1, 2]

Now I have the following query:

q=itm_field_skills:(1+OR+2)^5

So I've got the result, but the score is 5. I want to make a search request with boosting of each matching value to get score 10.


Solution

  • Absolute score values isn't something you can rely on. Your query does not mean that your score will be 5 or 10 - just that those terms are five/ten times more important than other parts of your query.

    If you look at the output of debugQuery, you'll see that the boost (5) is being applied separately to each term and then the scores for the terms are summed together afterwards.

    4.8168015 = sum of:
      1.2343608 = weight(..) [SchemaSimilarity], result of:
        1.2343608 = score(doc=0,freq=1.0 = termFreq=1.0
    ), product of:
          5.0 = boost <----
          0.3254224 = idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:
            6.0 = docFreq
            8.0 = docCount
          0.7586207 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:
            1.0 = termFreq=1.0
            1.2 = parameter k1
            0.75 = parameter b
            1.125 = avgFieldLength
            2.0 = fieldLength
      3.5824406 = weight(..) [SchemaSimilarity], result of:
        3.5824406 = score(doc=0,freq=1.0 = termFreq=1.0
    ), product of:
          5.0 = boost <---
          0.9444616 = idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:
            3.0 = docFreq
            8.0 = docCount
          0.7586207 = tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:
            1.0 = termFreq=1.0
            1.2 = parameter k1
            0.75 = parameter b
            1.125 = avgFieldLength
            2.0 = fieldLength