Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use function query for boosting score in Solr

I working on a Solr 4 for optimizing my solr results rank based on popularity rank stored in Index.

Now when someone searches, apart from relevancy rank, I want to influence relevancy rank using popularity rank. The simplest formula could be:

new relavancy rank = score * popularityrank

I have been looking at Solr function query at http://wiki.apache.org/solr/FunctionQuery#product to achieve the same however, I'm not sure how to get it to work. I didn't get how to get score multiplied using product function. Trying to get it done, I always get error as field not defined.

Now I can use boost as defined here How to boost fields in solr, but I have additional logic/requirement where I want to use functional query provided by Solr.

For example, I have tried with following simple query that seems to work

http://solr:8983/solr/select?q=hp%20laptop&defType=edismax&fl=Id,Name,score&bf=product%28$v1,$v2%29&v1=Id&v2=2

Now, for my actual requirement, I want to take score as $v2, however I am not able to find how to do this.

Any help is highly appreicated.

like image 776
Krutal Modi Avatar asked Nov 09 '13 10:11

Krutal Modi


1 Answers

You can try using the _val_ hook provided by Solr.

For instance, in order to sort by score * popularityrank, try using this

http://solr:8983/solr/select?q=hp%20laptop&_val_="product(score,popularityrank)"
like image 183
Srikanth Venugopalan Avatar answered Sep 21 '22 18:09

Srikanth Venugopalan