Assign weight to a integer column for Sphinx search

Posted by Daniel on Stack Overflow See other posts from Stack Overflow or by Daniel
Published on 2010-03-25T15:40:36Z Indexed on 2010/03/25 15:43 UTC
Read the original article Hit count: 196

Hello:

I have a note table with columns:

  • title :string
  • content :text
  • rating :integer

and a thinking_sphinx configuration:

define_index do
  indexes :title, :sortable => true
  indexes :content
end

Then I can search the notes and assign weights to title and content to define the order or the result:

Note.search "abc", :match_mode => :extended, :field_weights => {
  :title => 10,
  :content => 3
}

Now I want to assign a weight to the rating column

The type of the rating column is integer. The range of the rating is [1, 2, 3, 4, 5].

Can I just add weight at the :field_weights

:field_weights => {
  :title => 10,
  :content => 3,
  :rating => 5
}

or I need to do something else to make the note which has higer rating display first?

© Stack Overflow or respective owner

Related posts about sphinx

Related posts about thinking-sphinx