开发者

How to boost score of Solr search results based on criteria?

开发者 https://www.devze.com 2023-03-16 03:45 出处:网络
Background: 1 - I\'m using WebSolr for this search. 2 - I have two fields stored in websolr - name and id.

Background:

1 - I'm using WebSolr for this search. 2 - I have two fields stored in websolr - name and id.

I want to search for these entries based on name AND boost the search score based on this criteria:

if id in [x1,x2..xN] then +2
if id in [y1,y2..yN] then +1
else +0

From my re开发者_开发百科search, the answer lies in the following - Function query, or - DisMaxQParser

I have looked at the documentation but IMO its not very comprehensive.

Any help is appreciated.


You can use boosts. Try a query like

name:searchString AND ( id:[x1 TO xN] ^2 OR id:[y1 TO yN]^1)


In addition to hkn's approach, you could also use DisMax query parser boost queries:

q=queryString
&defType=dismax
&qf=…
&bq=id:[x1+TO+xN]^3
&bq=id:[y1+TO+yN]^2

(Untested, but should convey the idea.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号