Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6008107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:46:40+00:00 2026-05-23T01:46:40+00:00

I am using Thinking Sphinx for a Rails application. Everything works perfectly. I just

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:46:41+00:00Added an answer on May 23, 2026 at 1:46 am

    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:

    has 'items.ratings_sum/items.ratings_count',
      :as   => :rating,
      :type => :float
    

    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:

    Item.search 'foo',
      :sort_mode => :expr,
      :order     => "@relevance * rating"
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Thinking Sphinx in a Rails application combined with the jQuery autocomplete plugin
I'm using Thinking Sphinx for full-text search, following this video . I'd like to
I'm searching in two different modes using Thinking Sphinx: Full search on a single
I'm using a Sphinx search engine to perform my searches in a Rails project,
I am using Sphinx with the Thinking Sphinx plugin to search my data. I
I'm running sphinx, thinking sphinx on our rails3 application. I'm also using passenger on
I am using Ruby on Rails and the Thinking-Sphinx Gem with Sphinx as the
I installed Sphinx and Thinking Sphinx for ruby on rails 2.3.2. When I search
I've recently installed thinking-sphinx on my ruby on rails app. As first sight, everything
Im using thinking sphinx and it has become necessary to pull out the search

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.