Reputation: 248
I am using Solr search-engine in our Ruby On Rails app. using the sunspot gem for the implementation.
I have a couple of questions regarding the fulltext boosting mechanisem. Im trying to boost certain results up the result set if they meet certain condition, So lets say:
# Posts with pizza, scored higher if featured
Post.search do
fulltext 'pizza' do
boost(2.0) { with(:featured, true) }
end
end
i would expect all the Posts that contain 'pizza' and are featured = true, will get a score of 2.0 and all the rest to not get scored at all OR get a score of 0.
What actually happens is that all Posts with featured=true, get a score number which i cant predict (ie. 5.089861) regardless of the 2.0 i set in the search block.
Even if i increase the boosting number to 20.0 or 50.0, or if i add another boost if the Post matched another condition, the actual scores are still in the 5.XXX zone...
Moreover, Posts that are are featured=false, also have a score, of 0.09928045(ish) which i would expect to be an absolute 0.
Can anyone further explain how the scoring mechanism work, specifically:
Thanks.
Upvotes: 0
Views: 351
Reputation: 1152
Scoring doesn't work that way. Sunspot is literally boosting the score, it is not setting the score to the exact value. This is also why non-boosted fields returns a lower value.
This page describe how scoring (and boosting) works on the Lucene level.
Since this is not the way Sunspot / Solr / Lucene is intended to work, I doubt that there is a setting to allow you to fix the score, actually I can't think of a use case where you'd need to do this.
But if you really want to it should be fairly easy to implement your own solution :
Upvotes: 2