4

All my results are of type "active, inactive, historical" - this is a field indexed by Solr.

I want my results to be returned with a boost to type="active".

I could do ordering which will suffice, but its not great.

So, when a user searches for a term "sick", they get the most relevant results to sick, but with a higher boost for documents where its active.

Not just a sorted result set!

javanna
  • 59,145
  • 14
  • 144
  • 125
Mark
  • 2,522
  • 5
  • 36
  • 42

2 Answers2

6

You can use the edismax parser and the following boost query bq paramter to get your desired results to be boosted to the top...

 http://localhost:8983/solr/select/?q=sick&defType=edismax&bq=type:active^5.0

In this example you are adding a boost query to increase the relevancy of documents whose type is active.

Here are some more examples on the Solr Wiki DisMaxQParserPlugin page.

Paige Cook
  • 22,415
  • 3
  • 57
  • 68
3

The above example will create an additive boost. If you want an multiplicative boost for "type=active" you could add:

&boost=if(termfreq(type,"active"),2,1)

Which gives a factor 2 boost for "type=active"

kraftb
  • 625
  • 5
  • 15
  • This boost method is recommended in this great article describing the different boost methods: http://nolanlawson.com/2012/06/02/comparing-boost-methods-in-solr/ – Fractalf Nov 19 '14 at 14:46