Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
529 views
in Technique[技术] by (71.8m points)

lucene - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...