开发者

Ordering results by relevance using Solr search

I'm new to Solr search and trying to get a grasp on how to handle ordering of results. I'm using Ruby on Rails together with the Sunspot gem to interface with Solr.

I have an Article model, that has the following fields that are indexed:

text Title
text AuthorNames
integer NumberOfReviews

I'd like to be able to perform a search on Solr where:

  • Exact title matches are returned before anything else
  • Positive weighting is given prop开发者_运维问答ortionally to Articles with a larger NumberOfReviews

Ideally, I'd also like to be able to do something like Google where near misses and typos are also found to a certain extent, and alternative searches are suggested when it seems like the user might have made a mistake, though I'm not sure this is possible.

Can anyone help or point me in the right direction? Thanks in advance!


  1. "Weighting" is usually called "boosting" in Solr/Lucene jargon.
  2. Take a look at dismax queries and its parameters, there's a lot of tuning you can do there. For example you can use the bf parameter to boost articles with larger NumberOfReviews.
  3. Mistake checking, alternative suggestions: see SpellCheckComponent
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜