开发者

Solr/Lucene is it possible to order first by relevance, and then by a second attribute?

In Solr/Lucene is it possible to order fir开发者_开发百科st by relevance, and then by a second attribute?

As far as I can tell if I set an ordering parameter, it totally overrides relevance, and sorts by the ordering parameter(s).

How can I have results sorted first by relevance, and then in the case of two entries with exactly the same relevance, giving the nod to the item that, say, comes first alphabetically.

If it makes any difference I'm using Solr through Sunspot in Ruby on Rails.


Solved my own problem!

The keyword score can be passed to order the result by relevancy.

So in Rails Sunspot terms:

Article.search do
  keywords params[:query]
  order_by :score, :desc
  order_by :name, :asc
end
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜