Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr boosting result by field value

I am querying a solr server for locations. Those location documents also have a field "country_code" which contains values like US, GB, DE, ...

Under certain circumstances I want to boost results with specific country codes so that I am able to prioritize my results by country.

For example:

?q=york

Let's say the user is from Great Britain and is searching for York ... At the moment he finds some Yorks in the US first, then the one in England.

I want to be able to specify that for this query British results should be on top. I found that this should be possible via dismax and bq, something like that:

?q=york&dismax=true&bq=country_code:GB^20.0

But that doesn't work as expected, now York from Guatemala (country_code GT) is on top, the GB ones are not to be seen.

Help please ;-)

like image 483
Cornelius Avatar asked Jun 01 '12 10:06

Cornelius


Video Answer


2 Answers

Ok, what I did with dismax in my question is working, I just had the boost value way too low. Changed it from 20 to 20000 and it's working just fine.

like image 63
Cornelius Avatar answered Oct 12 '22 23:10

Cornelius


The bq param of dismax is additive, meaning it adds to the final score. There is a boost param in the new edismax parser, which multiplies the boost function value to the final score, edismax boost.

like image 39
randroid Avatar answered Oct 13 '22 00:10

randroid