I am using Thinking Sphinx for a Rails application. Everything works perfectly. I just want my search results to take the ratings of my items into account (items with higher relevance appear first).
define_index('item') do
# ...
indexes 'items.ratings_sum/items.ratings_count',
:as => :rating,
:sortable => true
# ...
end
I used the “sort_mode” option, but it puts too much emphasis on the rating, not enough on the keywords.
How can I use this rating to influence to order of the search results?
Firstly, you’re going to want that rating value as an attribute – it’s not like people are going to search for it, right? And it’s better if it’s stored as a float? So:
The next step – and this is something you’ll have to tweak to get it exactly how you like – is to use the expression sort mode:
Maybe you only want the rating to have a 10% impact on the @relevance?
@relevance * (rating / 10). Or you just want to add the two?@relevance + rating. Play around with it until you find a solution you like.