views:

53

answers:

2

Hi!

I have model Products with columns:

name, number, description

Index defined for this model looks like this:

define_index do
  indexes :name, :sortable => true
  indexes :number
  indexes :description
  where "amount > 0"
  has :price
end

Since in description can be lots of random words I want to exclude it from searching sometimes (when user clicks chceckbox 'don't search in descriptions').

I went to the sphinx page and found following:

@(name, number) *pencil* *123*

And it seems like I don't understand how sphinx works. When I execute search

*pencil* *123*

word 'pencil' is found in name and '123' is found in number and I get 1 result. But when I execute

@(name, number) *pencil* *123*

no results are found.

Is searching by columns somehow different?

A: 

Hi Adrian

You can only search on fields when using the :extended match mode - Thinking Sphinx sets this automatically if you use :conditions - but you're constructing a multi-field query yourself, hence why this isn't happening. Try this:

Product.search "@(name, number) *pencil* *123*", :match_mode => :extended

Hope this helps.

pat