To clarify the difference:

- "bf" is a special param of the dismax parser, which does an *additive* 
boost function - that function can be something as simple as a numeric 
field

- alternatively, you can use the "boost" parser in your main query string, 
to wrap any parser (dismax, edismax, standard, whatever....) in a 
*multiplicitive* boost, where the boost function can be anything

- multiplicitve boosts are almost always what people really want, additive 
boosts are a lot less useful.

- when specifying any function, you can use variable derefrencing for any 
function params.

So in the example Upayavira gave, you can use any arbitrary query param to 
specify the function to use as a multiplicitive boost arround an arbitrary 
query -- which could still use dismax if you want (just specify the 
neccessary parser "type" as a localparam on the inner query, or use a 
defType localparam on the original boost query).  Or you could explicitly 
specify a function that incorporates a field value with some other 
dynamic params, and use that entire function as your multiplicitive boost.

a more elaborate example using the "bin/solr -e techproducts" data...

http://localhost:8983/solr/techproducts/query?debug=query&q={!boost%20b=$boost_func%20defType=dismax%20v=$qq}&qf=name+title&qq=apple%20ipod&boost_func=pow%28$boost_field,$boost_factor%29&boost_field=price&boost_factor=2

    "params":{
      "qq":"apple ipod",
      "q":"{!boost b=$boost_func defType=dismax v=$qq}",
      "debug":"query",
      "qf":"name title",
      "boost_func":"pow($boost_field,$boost_factor)",
      "boost_factor":"2",
      "boost_field":"price"}},







: Date: Tue, 14 Jul 2015 21:58:36 +0100
: From: Upayavira <u...@odoko.co.uk>
: Reply-To: solr-user@lucene.apache.org
: To: solr-user@lucene.apache.org
: Subject: Re: Dereferencing boost values?
: 
: You could do 
: 
: q={!boost b=$b v=$qq}
: qq=your query
: b=YOUR-FACTOR
: 
: If what you want is to provide a value outside.
: 
: Also, with later Solrs, you can use ${whatever} syntax in your main
: query, which might work for you too.
: 
: Upayavira
: 
: On Tue, Jul 14, 2015, at 09:28 PM, Olivier Lebra wrote:
: > Is there a way to do something like this: " bf=myfield^$myfactor " ?
: > (Doesn't work, the boost value has to be a direct number)
: > 
: > Thanks,
: > Olivier
: 

-Hoss
http://www.lucidworks.com/

Reply via email to