Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr - How to boost score for early matches?

Tags:

solr

How can I boost the score for documents in which my query matches a particular field earlier. For example, searching for "super man" should give "super man returns" a higher score than "there is my super man". Is this possible?

like image 840
techfoobar Avatar asked Aug 22 '12 09:08

techfoobar


People also ask

How Boost works in SOLR?

The default boost for a field is 1, so setting a value between 0 and 1 would down boost the document. It is also possible to add different boosts to different fields of a document. The only requirement here is that the boosted fields must store the norms (“omitNorms” attribute in the schema must be set to “false”).

What is SOLR boost?

The process of giving higher relevance to a set of documents over others is called boosting, Solr support at least four ways of changing the boost factors of the documents: By boosting terms q=black^2.0 .

How SOLR score is calculated?

Lucene uses the TF/IDF scoring algorithm to give initial relevance scores to each document as served up in a search result. You can set all your QF params to be between [0,2] to get a pseudo normalized curve in the QF part of the score influence.

What is BQ in SOLR?

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.


2 Answers

Check for options @ Ranking-based-on-term-position

like image 152
Jayendra Avatar answered Sep 22 '22 05:09

Jayendra


Solved it myself after reading a LOT about this online. What specifically helped me was a reply on nabble which goes like (I used dismax, so explaining that here):

  • Create a separate field named say 'nameString' which stores the value as "_START_ <actual data>"
  • Change the search query to "_START_ <actual query>"
  • Add the new field nameString as one of the fields to look in in the query fields param (qf)
  • While searching use the parameter pf (phrase field) as the new field nameString with a phrase slop of 1 or 2 (lower values would mean stricter searching)

Your final query params will be something like:

q=_START_ <actual query>
defType=dismax
qf=name nameString /* look in name field as well as nameString field */
pf=nameString /* phrase field in nameString */
ps=2 /* phrase slop */
like image 30
techfoobar Avatar answered Sep 22 '22 05:09

techfoobar