Is aaf multi_search broken?

Hi all,

I want to use acts_as_ferret’s multi_search to search two model classes
(Reviewable and Blog) at a time like

@results = Reviewable.multi_search(“jemen”, [Blog])

and I’m always getting the error

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.map

#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:131:in
id_multi_search' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:113:inmulti_search’
#{RAILS_ROOT}/app/controllers/search_controller.rb:53:in `search’

I have configured indexing like this:

acts_as_ferret :fields => [:index_text, :index_locations], :single_index
=> true
acts_as_ferret :fields => [:index_text, :index_locations], :single_index
=> true

Maybe I’m doing something wrong?

Thanks,

Starburger

Sorry, the above error is for the bleeding edge version (wrong cut &
paste). Nevertheless for the stable version I get (in the same
scenario):

can’t convert String into Array
RAILS_ROOT: C:/INSTAN~2.6-W/rails_apps/abb/config/…

Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/multi_index.rb:11:in +' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/multi_index.rb:11:ininitialize’
C:/INSTAN~2.6-W/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/inflector.rb:250:in
inject' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/multi_index.rb:10:ineach’
#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/multi_index.rb:10:in
inject' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/multi_index.rb:10:ininitialize’
#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/local_index.rb:191:in
new' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/local_index.rb:191:inmulti_index’
#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/local_index.rb:112:in
id_multi_search' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:117:inid_multi_search’
#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:98:in
multi_search' #{RAILS_ROOT}/app/controllers/search_controller.rb:53:insearch’

Hi!

On Fri, Jun 01, 2007 at 11:00:24PM +0200, Starburger wrote:

You might have expected an instance of Array.
The error occurred while evaluating nil.map

[…]

I have configured indexing like this:

acts_as_ferret :fields => [:index_text, :index_locations], :single_index
=> true
acts_as_ferret :fields => [:index_text, :index_locations], :single_index
=> true

Maybe I’m doing something wrong?

just don’t use multi_search with :single_index => true. In the
single_index case, you tell find_by_contents what additional models to
search with the :models option:

@results = Reviewable.find_by_contents(“jemen”, :models => [Blog])
or
@results = Reviewable.find_by_contents(“jemen”, :models => :all)

this indeed looks a bit like an inconsistent API, however it’s this way
because in the single_index case you have only one Ferret index (hence
find_by_contents is used), while multi_search runs a combined search
across multiple Ferret indexes.

Maybe in a future version I’ll integrate the multi_search functionality
into find_by_contents, too.

Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa