开发者

Influencing Solr search results with a field value

I've recently started experimenting with Solr. My data is indexed and searchable. My problem is in the sorting. I have three fields: Author, Title, Sales.

I would like to search against the author & title fields, but have the sales value influence the scor开发者_运维技巧e so that matches with higher sales move toward the top, even if the initial match score is not the highest.

Simply sorting by sales does not produce valid results as a result with a near 0 score for the search term, but a lot of sales in general could end up above a perfect match for the term that has never been sold.

I am seeing results that, while great term matches, are not necessarily the product I want showing at the top of the list.


If you're using the dismax handler, you can add a boost function (bf) with the field you want to boost on, e.g.

http://...?q=foo&bf="fieldValue(sales)^1.5"

...to make the value of the sales figure give a bump. You can, of course, make the function more complex if you want to munge the sales data in some way.

More info is easily found.

You may also just want to do this at index time since the sales data isn't going to be changing on the fly.


You can also use Index-time boosting.
And here's detailed info on using function queries to influence scoring.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜