Additive Boost in Solr

If you use the dismax or edismax parser, there are three URL options that let you change the ranking: bf, bq, and boost. Boost seems to be the most flexible – in addition to the URL argument, there are ways to apply the boost on an entire document or field at index or query time.

Boost is a multiplication operation, as it is based on vector manipulation. Additive boost would seem to have less impact over the ordering of the results. E.g. adding 1, 2, 3, 4, and 5 to a set of scores will increase them, as would multiplying by 1, 2, 3, 4, and 5. For small scores the addition would have more weight than the score, and for large multiplications, this can show when a document is a strong winner for a query. Addition is particularly useful for use when using random numbers (if you choose numbers from 0 to 1, 0.1 + 0.1 is clearly quite different from 0.1 x 0.1).

You make additive changes to scores in Solr using the “bf” and “bq” query parameters, assuming you’re using dismax/edismax. The “bf” option allows you to add the result of a function call or field, and the “bq” allows you to add score results from a second query. So, if you were storing a random number you want to add to the score, you’d use bf, but if you want to boost by how relevant the query is to a second query, you could use bq, e.g. to rank exact matches somewhat higher.

Notably, you can also use function calls in these arguments, so you can do things like add two fields together (or other mathematical operations), which allows you do all kinds of great stuff:

bf:add(talk_day_i,talk_year_i)

If you do this, you should take a look at the debug output, which shows explain plans – I think something complex is likely to slow the query engine down, and the score outputs are not entirely what you’d expect, as they get normalized before you see them.

For example:

26.16295 = sum of:
  0.70710677 = *:*, product of:
    1.0 = boost
    0.70710677 = queryNorm
  25.455843 = FunctionQuery(sum(int(talk_day_i),const(5))), product of:
    36.0 = sum(int(talk_day_i)=31,const(5))
    0.70710677 = boost
    1.0 = queryNorm
",
Looking for a good software development book? The Phoenix Project is a novel(!) about a failing software project, which I found to be an interesting read.
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *