to the ones i defined in my model? for example if in the model i specify
acts_as_ferret to index only column 1, 2, and 3 in my table…how can i
perform a search just for column 1 if need be.
for example, id like to give the user the ability to just search on
title name vs description, etc…
to the ones i defined in my model? for example if in the model i specify
acts_as_ferret to index only column 1, 2, and 3 in my table…how can i
perform a search just for column 1 if need be.
for example, id like to give the user the ability to just search on
title name vs description, etc…
thanks!
You prepend the search with the field-name and a colon. For example:
If params[:category] is the name of the field you want to search then
yes, almost. You should also put brackets around params[:query] so the
whole query is restricted to the field.
hello,
i would like to use find_by_contents, have it search the table for
things that match my query, only if a column field is a certain value.
for example i have an application for all the states in usa. If i am
using the NJ search box, i would only like to limit my searches for
where the state name is equal to new jersey.
can i do this?
from the above example it seems like i am looking for something like
this?
and it should work. if you store the state acronym in the state field,
it might be a good idea to give :index => :untokenized as an option for
this field in your call to acts_as_ferret:
acts_as_ferret :fields => {
:content => {},
:state => { :index => :untokenized },
… any other fields you want to have indexed
}
this works great for i.e. having a select box to let the user select a
state he wants to search in. Generally, not tokenizing a field is a good
thing whenever you expect exact matches on a field, or want to sort your
results using this field. You can have a look at the Ferret API docs
(class FieldInfo) for more options and their explanations.
cheers,
Jens
–
webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer [email protected]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.