Search on fields

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,

On 7/21/06, Vanesa M. [email protected] 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)

Thanks David, This works.
-Vanesa

David B. wrote:

On 7/21/06, Vanesa M. [email protected] 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)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs