views:

87

answers:

1

Hi all,

I have started to use acts_as_ferret to add text searching to an application. In my example app (another blog!) I have defined and index in my article as follows:

acts_as_ferret :fields => [:title, :body]

I'd like an option to search on a single field e.g. get me all article where the title contains "rails", rather than all articles where the title or body contains "rails".

How can I constrain my search to a single field within the index?

Cheers,

Adam

+2  A: 

You can specify which fields to search in the find_by_contents() call, something like "title:rails" should limit the search to just that field.

Taken from http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial under the 'Additional Query Strings' heading

Marc Roberts