Forum: Ferret aaf 0.4.4 index population bug?

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.
9f428b4974fd9d11e47a4d26541fb2a3?d=identicon&s=25 Richard Surname (richard13)
on 2009-08-20 13:22
Hi Jens,

I am using Ferret 11.6 and aaf 0.4.4. I am using LocalIndex in
development environment as I have not gotten to production stage yet.

There seems to be a bug where the Ferret index is not being populated
versus the old behavior in 0.4.3.

I am calling acts_as_ferret in my models as opposed to using aaf.rb
(since the latter is not documented anywhere but in the code!). Also, at
this point, no index exists in index directory.

It seems, based on my understanding of the source, that when
ensure_index_exists/rebuild_index is initially called, internally via a
long chain of methods, from acts_as_ferret (when the model class is
loaded), index_definition[:registered_models] is the empty array. Hence,
index.index_models(models) doesn't populate the newly created Ferret

When ensure_index_exists is called the second time around, internally
via a long chain of methods from find_with_ferret, rebuild_index doesn't
get called again because #{index_definition[:index_dir]}/segments exists
due to the Ferret index coming into existence in the first rebuild_index
call. It's a shame because this time around
index_definition[:registered_models] IS populated due to an earlier call
to index.register_class(clazz, options). Had rebuild_index been called,
the Ferret index would get poopulated with documents.

Could you confirm my understanding please? If I read the code correctly,
then it seems the fix should reside on this line
index_definition[:registered_models] = Object.const_get(name) | []

I don't use ActsAsFerret::define_index directly but I suppose for those
who do, my suggestion would break the code for them. It would be nice if
you could come up with something that would work for all supported use
cases since it took days for me to get this far.

This topic is locked and can not be replied to.