Forum: Ferret Is there any working way to search multiple indexes?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Joshua B. (Guest)
on 2006-05-06 00:14
(Received via mailing list)
I'm running from the trunk, and hitting road blocks no matter which way
to search across multiple indexes.

I tried a MultiSearcher, but I can't pass a string for the search query "iraq"
TypeError: wrong argument type String (expected Data)

So I tried creating a QueryParser to pass, but I can't get the fields
the reader
NoMethodError: undefined method `get_field_names' for

and even if I could, I cant pass any fields to the QueryParser
qp.fields = ["title"]
NoMethodError: undefined method `fields=' for

So I tried using the MultiReader, like acts_as_ferret does, but it won't
take any arguments
@reader =
ArgumentError: wrong number of arguments (1 for 0)

Is everything I'm trying to do unimplemented in the c version, or am I
overlooking something obvious?

David B. (Guest)
on 2006-05-06 04:47
(Received via mailing list)
Hi Joshua,

The best place to check how to use the MultiSearcher is the
MultiSearcher unit tests;


Create a MultiSearcher like this;

    @multi =[,])

You can have as many IndexSearchers as you like. You actually need to
pass a query to both IndexSearcher and MultiSearcher. Strings are not
allowed in Ferret 0.9.1. That may change in future versions. So do
something like this;

  def do_search(query)
    @query_parser ||=['date', 'field',
'cat'], :analyzer =>
    query = @query_parser.parse(query) if (query.is_a? String)

Hope that helps.

This topic is locked and can not be replied to.