First of all, sorry if this appears in the list twice - i was awaiting
moderation all day and then finally joined the list properly and sent
this
direct.
Previously, for all my ferret searches, i was using find_by_contents,
like
this:
That all worked fine. We’ve upgraded to the latest ferret/a_a_f,
though,
which no longer uses find_by_contents: i believe we’re supposed to use
find_with_ferret instead. However, if i do the equivalent, with
find_by_contents replaced with find_with_ferret, then the ‘multi’ part
doesn’t work: i get the same results as if i didn’t pass multi at all.
My ferret-indexed classes all have “:store_class_name => true”, which i
read
was necessary for multi searches. Can anyone help please?
(To make life a bit more complicated, two of the classes extend one of
the
others, and i’d like a ferret search on the superclass to return results
from both subclasses. However, i’d settle right now for just having a
multi-model search that works)
what you’re experiencing is a result of the recent refactorings I did to
the aaf code base. Sorry for the inconvenience this has caused you - I
didn’t find the time to document this properly yet.
I moved the multi search functionality from the class level methods
(like find_with_ferret) into the ActsAsFerret namespace. It has always
been a bit inconsistent calling find_with_ferret on one class, passing
in any other classes to search in via the :multi option.
To get multi search back, you should use ActsAsFerret::find like this:
I just remembered the second part of my last question…
I have a superclass, Resource, which has two subclasses, TeachingObject
and
LearningObject. All the records that are saved are one of the
subclasses.
However, i’d like to be able to do a ferret search on Resource and get
both
kinds of subclass, like when i do Resource.find(), which returns both
kinds.
I’m having problems with the index though: TeachingObject and
LearningObject both have :store_class_name => true, and they have their
own
indexes. When i try to build the index for Resource, it crashes with
the
following trace, whether i have :store_class_name => true set for
Resource
or not. Any ideas, anyone?
thanks, max
NoMethodError: You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.each_pair
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/instance_methods.rb:130:in to_doc' from /home/jars/rails/lesson_planner/branches/bundles/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/object/misc.rb:28:inreturning’
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/instance_methods.rb:124:in to_doc' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:19:inindex_records’
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:19:in each' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:19:inindex_records’
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:29:in measure_time' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb:18:inindex_records’
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:52:in index_model' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/class_methods.rb:79:inrecords_for_rebuild’
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in transaction' from /home/jars/rails/lesson_planner/branches/bundles/vendor/rails/activerecord/lib/active_record/transactions.rb:80:intransaction’
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/class_methods.rb:74:in records_for_rebuild' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:51:inindex_model’
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:39:in index_models' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:39:ineach’
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb:39:in index_models' from /home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/local_index.rb:54:inrebuild_index’
from
/home/jars/rails/lesson_planner/branches/bundles/vendor/plugins/acts_as_ferret/lib/class_methods.rb:28:in
`rebuild_index’
what you’re experiencing is a result of the recent refactorings I did to
the aaf code base. Sorry for the inconvenience this has caused you - I
didn’t find the time to document this properly yet.
I moved the multi search functionality from the class level methods
(like find_with_ferret) into the ActsAsFerret namespace. It has always
been a bit inconsistent calling find_with_ferret on one class, passing
in any other classes to search in via the :multi option.
To get multi search back, you should use ActsAsFerret::find like this:
i’ve been searching on the very same issue all afternoon.
using find_with_ferret gave the :store_class_name error (although all my
models have got :store_class_name => true, as specified in the ferret
gotchas).