Sam Giffney wrote:
> mix wrote:
>> mix wrote:
>>> but i've just another problem.... if i search something like +, "", <abc
>>> and so on it found me all records O_o do you know why?
>>> is it correct the query ? about the title:#{query} any words? :(
>>> thanks :)
>
> Maybe just me, but I can't understand your question. Can you try
> rephrasing or perhaps including some code and results?
sure...so, i've a model which has this code:
----------------
acts_as_ferret :fields => {:title => {},
:all_categories => {},
:user_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, extra)
return nil if query.nil? or (query == '')
query += " +all_categories:#{category_id}
+bought_at_int:<#{15.days.from_now.to_i} +gift:false #{extra}"
sort = Ferret::Search::SortField.new(:expires_at_int, :type =>
:byte, :reverse => false)
self.find_by_contents(query, {:limit => :all, :sort => sort}, {
:include => [:user, :categories] })
end
----------------
the search controller is:
def show
@category = Category.find_by_id(params[:category_id] || 1)
@obj = Model.full_text_search(params[:query], @category.id, '')
end
-----------------
(i use the extra variable in another part to search for a user, like: '
+user:1')
anyway, if i search for a title (which i have in the db) 'test', ferret
found me without problem, or another title like 'fishing guide', and the
result is pretty good (ok ok, is perfect :)), but when i search for
something like: '+', '""', '<abc' ferret found me all the records in the
db.... why? :(
and so on it found me all records
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk