Rails association and multiple indexes

Hi!

If I have two models, Product and Manufacturer, of course Product
belongs_to :manufacturer.

A search engine would allow a user to look for a product by its name or
manufacturer. Is it better to define a method like:

def searchable_field
“#{name} #{manufacturer.name}”
end

and add it as indexable field (acts_as_ferret :fields =>
[‘searchable_field’])…

Or maybe that it is more advisable to index different fields:

Product < ActiveRecord::Base
acts_as_ferret :fields => [‘name’, ‘manufacturer_name’]

def manufacturer_name
  "#{manufacturer.name}"
end

end

Thanks in advance.

On 10/22/06, Rodrigo A. [email protected] wrote:

end
“#{manufacturer.name}”
end
end

Thanks in advance.

Hi Rodrigo,

It’s better to index individual fields. You can easily search both
fields like this:

"name|manufacturer_name:(#{query})"

I can’t really think of any advantages to putting buth fields into the
one search field.