hi, i’m trying ferret, i’ve a model which has some records and two of
them have a title with the word ‘again’ (one or more time), so i’ve
tried to do a search for ‘again’, but i didn’t found anything…i’ve
edited the title with ‘test again’, searched for ‘test’, and i’ve found
them…another time with ‘again’, but nothing, so i’ve tried with ‘my
test’…searched for ‘my’, and…nothing…is it a problem or like a
“feature”?
another little problem i’ve found is that i’ve written this for the
search:
acts_as_ferret :fields => {:title => {},
:category_id => {},
:bought_at_int => {:index =>
:untokenized_omit_norms, :term_vector => :no},
:gift => {:index =>
:untokenized_omit_norms, :term_vector => :no}}
def self.full_text_search(query, category_id)
return nil if query.nil? or (query == ‘’)
query += " +category_id:{category_id}
+bought_at_int:>#{Time.now.to_i} +gift:false"
sort = Ferret::Search::SortField.new(:bought_at_int, :type =>
:byte, :reverse => false)
self.find_by_contents(query, {:limit => :all, :sort => sort}, {
:include => [:user] })
end
this works…initially i’ve tried with
query = “+title:#{query} +bought_at_int:>#{Time.now.to_i}
+gift:false”
but this doesn’t wok, can someone tell me what? i think is the
same…(the second is better because the query is only for the title
and not for other fields)