开发者

Is it possible to tweak Solr hit relevance score based on length of content?

开发者 https://www.devze.com 2023-02-09 00:40 出处:网络
I have a Rails app using sunspot to do searches against a table with records of varying sizes. I want to adjust the score of the 开发者_C百科hit depending on how large a certain field is. This is to p

I have a Rails app using sunspot to do searches against a table with records of varying sizes. I want to adjust the score of the 开发者_C百科hit depending on how large a certain field is. This is to punish articles that have very little content but happens to have the term being searched for showing up at the top. Is that possible?


One technique: compute the body length at insertion time and give the whole document a Boost based on its higher length - you'd supply this Boost manually, for each document at index-time.

See this FAQ: http://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_increase_the_score_for_specific_documents


This mailing list thread seems to kind of answer your question - and brings up another point that you might be thinking about this wrong.

http://osdir.com/ml/solr-user.lucene.apache.org/2010-05/msg00916.html

This quote is illustrative: "I have to ask, though, why you want to sort this way? The relevance calculations already factor in both term frequency and field length. What's the use-case for sorting by field length given the above?"

0

精彩评论

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