solrsolr-query-syntaxsolr-boost

Customized Boosting in Solr


I'm using Solr in a search app, where data has been divided in different types but in same collection. Each document in collection has d_type field which defines the type of data.

Example

Consider I have 5 type of data

d_type=ds1
d_type=ds2
d_type=ds3
d_type=ds4
d_type=ds5

I want to apply boosting but based on user preferences. I have stored user preferences in other collection against each user. Now on run time I call user preferences collection and fetch preferences of logged-in user in an object i.e

{
"1" : "ds4",
"2" : "ds5",
"3" : "ds1",
"4" : "ds3",
"5" : "ds2",
}

ds4 has highest priority and ds2 has the least priority in above example I've tried adding bq with Solr query but did not get expected result

/select?bq=d_type:ds4^5+d_type:ds5^4+d_type:ds1^3+d_type:ds3^2+d_type:ds2^1

Above query does not work as expected. Please tell me what is wrong here.

solr version : 7.7.2

Thanks


Solution

  • I fixed this problem by

    /select?bq=d_type:ds4^500&bq=d_type:ds5^400&bq=d_type:ds1^300&bq=d_type:ds3^200&bq=d_type:ds2^100&defType=edismax