Thursday, February 6, 2014

Solr Simple Boosting

This is a very simple method to implement boosting the relevancy of search results.  You can append a boost value after query parameters.  You can do that directly in the "q" value like this:




The "^2" is the boost value.  The higher the number, the higher the relevancy if the search term is matched in the corresponding field.  In this example, we are searching for the term "new york" in the fields, "_city" and "_institute_name".  All results that match "new york" in the "_institute_name" field will rank higher with a greater score and will be at the top of the result set.


The second way to approach this is to enable "dismax" and put the search fields and boost values in the "qf" field and put the search term in the "q" field like this:






If you look at the "fl" field, you will see a few column names.  This is the list of fields to display on the result set.  The "score" field is a calculated field that is available for all indexed documents.  It is not defined in the schema.xml markup but it is available to use when analyzing relevancy.





Keep in mind that boosting will only work if text fields are assigned tokenized text fields such as "text_en".  Non-tokenized fields like "string" will not work.



1 comment:

  1. You must do that because you can't just join one in a group. And you must have four people for this also, otherwise random people can come in your game if its 3 or 5+ people.

    hearthstone boost

    ReplyDelete