Reputation: 2211
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 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?
Upvotes: 0
Views: 608
Reputation: 32748
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
Upvotes: 2
Reputation: 32748
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?"
Upvotes: 0