Hi, I wonder if it is possible to perform the "find_by_contents" on a subset of fields indexed in acts_as_ferret.If so, how? In my code I have: acts_as_ferret (:fields => [''title'', ''focus'', ''purpose'']) However, I like to have two search options one on all fields and one only on the title. Any help is most appreciated. Thanks, -- Posted via http://www.ruby-forum.com/.
On 7/21/06, Vanesa Mirzaee <vanesam at ece.ubc.ca> wrote:> Hi, > > I wonder if it is possible to perform the "find_by_contents" on a subset > of fields indexed in acts_as_ferret.If so, how? > > In my code I have: > > acts_as_ferret (:fields => [''title'', ''focus'', ''purpose'']) > > However, I like to have two search options one on all fields and one > only on the title. > > Any help is most appreciated. > > Thanks,Hi Venesa, You can search a specific field by prepending the query with the field name. For example %{title:"Lord of the Rings" purpose:"enjoyment"}. Or, if you don''t want the users typing in field names, you could modify the query_string to search only the title field like this; query_string = "title:(#{query_string})" Hope that helps, Dave PS : (Jens, please correct me if this won''t work with acts_as_ferret)
Thanks David, This works. -Vanesa David Balmain wrote:> On 7/21/06, Vanesa Mirzaee <vanesam at ece.ubc.ca> wrote: >> only on the title. >> >> Any help is most appreciated. >> >> Thanks, > > Hi Venesa, > > You can search a specific field by prepending the query with the field > name. For example %{title:"Lord of the Rings" purpose:"enjoyment"}. > Or, if you don''t want the users typing in field names, you could > modify the query_string to search only the title field like this; > > query_string = "title:(#{query_string})" > > Hope that helps, > Dave > > PS : (Jens, please correct me if this won''t work with acts_as_ferret)-- Posted via http://www.ruby-forum.com/.