2

I'm just starting to learn about boosting in Solr, and so far I've been able to add boost queries based on some specific phrases like: bq=manufacturer:sony^2. However, I'm now looking to apply logic to a boost and I'm not sure how to proceed.

Specifically, I already have a boost query with multiple terms like

bq = manufacturer:"sony"^2 name:"bob"^3 town:"place"^4 age:"40"^5

but I wanted to know if it was possible to add another term that is a collection of smaller terms such that if one or more match then the whole term is weighted higher for that given search result? Something like:

bq = manufacturer:"sony"^2 (name:"bob" OR town:"place" OR age:"40")^5

where the multi-term in parenthesis has one associated weight (5) that is only "activated" if one or more of its sub terms match.

Does something like this just belong in a bq or is this closer to a boost function? I'm sort of confused as to what the main differences are.

Thanks for any help.

muZero
  • 948
  • 9
  • 22

1 Answers1

3

As per Solr documentation https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser

The bq (Boost Query) Parameter The bq parameter specifies an additional, optional, query clause that will be added to the user's main query to influence the score.

The bf (Boost Functions) Parameter The bf parameter specifies functions (with optional boosts) that will be used to construct FunctionQueries which will be added to the user's main query as optional clauses that will influence the score.

You would use the bf parameter if you want to derive a value from a field using one of the native Solr Functions.

In your case you are using the fields as it is and not using any native Solr functions on them. Therefore for your case bq will work fine.

You could chain several bq parameters in your query to get the desired output. for eg you can do :-

q=*:*&bq=manufacturer:sony^2&bq=name:bob^3&bq=town:place^4&bq=age:40^5

You can modify above query to suit your needs.

Max08
  • 955
  • 1
  • 7
  • 16
  • Ah that makes sense. Further-- I already have a handful of fields and values in bq with their associated weights. I wanted to know if there was a way to add an additional term that is a combination of OR's. Something like `bq=term1^weight1 term2^weight2 (manufacturer:sony OR name:bob OR town:place OR age:40)^weight3`? Thanks! – muZero Jul 17 '17 at 18:42