Forum: Ruby on Rails Thinking_sphinx set weighting

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
330edb8dc8bbc5a824984cf46e941b2f?d=identicon&s=25 Tam Kbe (tkbeili)
on 2008-10-11 21:09
Hello,

I'm using Sphinx search engine with thinking_sphinx Ruby on Rails plugin
to interface with it. I use it as follows:
    @topics = Topic.search(@search_phrase,
              :sphinx => {:limit => $SEARCH_TOPICS_PAGE_COUNT, :page =>
@page,:weights => [100,60,20,20,10]},
              :per_page => $SEARCH_TOPICS_PAGE_COUNT, :page => @page)

with indexing code in side topic.rb:
 define_index do
    indexes title,  description
    indexes comment.description, :as => :comment_description
    indexes poll.poll_question, :as => :poll_question
    indexes categories.name, :as => :category_name

    has created_at,rating_score
  end

it works fine except for weighting! I assume it should give title a
weight of 100 as it's first description 60 and so on...

When I search it returns good results but it doesn't sort it very well
according to weighting! so if I have a keyword that exist in one topics
title and another topics comment I want the one with the keyword in the
title to show first. I might be setting the weights in wrong way? any
ideas?

Thanks,

Tam
This topic is locked and can not be replied to.