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 ;-)
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With