Usage and benefits of single-index with AAF

The documentation states:

“single_index: set this to true to let this class use a Ferret index
that is shared by all classes having :single_index set to
true. :store_class_name is set to true implicitly, as well as
index_dir, so don’t bother setting these when using this option. the
shared index will be located in index/<RAILS_ENV>/shared .”

[1] If I’m reading the code correctly, it seems that single-model
searches will behave the same as before, and AAF/Ferret will add the
extra column to the query for me. Is this correct?

[2] How can I take advantage of the single-index when doing multi-
model searches? Through which model will I perform the query? Or do I
need to do this with raw Ferret queries and not through AAF?

[3] Are there other advantages or gotchas that I’m missing?

Thanks,
John

On Thu, Nov 30, 2006 at 12:50:32PM -0500, John B. wrote:
[…]

[1] If I’m reading the code correctly, it seems that single-model
searches will behave the same as before, and AAF/Ferret will add the
extra column to the query for me. Is this correct?

yep.

[2] How can I take advantage of the single-index when doing multi-
model searches? Through which model will I perform the query? Or do I
need to do this with raw Ferret queries and not through AAF?

there’s a secret option called :models to find_by_contents, which you
can use to specify any additional models you want to search in. I just
committed a fix adding that piece of documentation, and a fix to set the
ferret_score attribute on results when using single_index.

[3] Are there other advantages or gotchas that I’m missing?

generally the whole single_index thing seems to be less commonly used
and therefore is less tested in the wild.

Also with single_index each object in a result set is fetched with a
single call to find, which clearly is not acceptable if a search returns
a serious amount of results. Patches welcome :wink:

I’d normally suggest using the multi-index search feature as an
alternative to single_index (it’s possible to search across multiple
indexes at once with the multi_search method), but unfortunately this
yields segfaults with recent Ferret versions (i think >= 0.10.10).

cheers,

Jens


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