Reputation: 2542
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!
Upvotes: 4
Views: 3168
Reputation: 655
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"
Upvotes: 3
Reputation: 22555
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.
Upvotes: 6