Gary Sieling

Solr: bf vs bq

The “bf” and “bq” URL parameters are arguments to the dismax and edismax parsers in Solr.

“bf” stands for “boost function”, and “bq” is “boost query”. These are useful because unlike “boost” they are additive (boost does multiplication).

“Boost field” adds the output of a field to the score.

However, this is a little more confusing than it first appears. Here, I’ve done “bf=add(talk_day_i, 5)”, just to show how two forms of addition can be combined.

The output of “bf” is being treated like a vector and normalized in some way, so it’s not as if you’re adding a specific value to the final score:

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
",

Just to fully understand this, lets then do this with “bq”:

bq=category_l2_ss:history

Here, we don’t see any additional values in the debug ouput for each row, because the score is already computed using the “boost” we’ve applied, but you can see that it is handled outside of the work that runs on each row.

"parsedquery": "(+MatchAllDocsQuery(*:*) category_l2_ss:history)/no_coord",
"parsedquery_toString": "+*:* category_l2_ss:history",
"explain": {
  "cc7096a2-8e08-4e86-a738-c96d73f0979c": "
     0.114599384 = sum of:
       0.114599384 = *:*, product of:
         1.0 = boost
           0.114599384 = queryNorm
  ",
  ... 
},
"QParser": "ExtendedDismaxQParser",
"altquerystring": null,
"boost_queries": [
  "category_l2_ss:history"
],
"parsed_boost_queries": [
  "category_l2_ss:history"
],
Exit mobile version