If I disable ferret in my environment file and then run a cron job
every hour to index the records that have been added/changed, do I
enable Ferret just in the script that does the hourly indexing? Or do
I somehow need to tell the process that runs the Ferret DRB server
that it should start writing to the index again? Thanks in advance.
Erik
Follow Up. I have 5 mongrels and a ferret drb server running on the
same machine. In environment.rb I disable ferret like so:
MyModel.disable_ferret
I have a script that runs every hour that does the following:
MyModel.enable_ferret
MyModel.bulk_index all_records_created_or_changed_in_the_last_hour
Now, ClassMethods defines bulk_index as:
def bulk_index(*ids)
ids = ids.first if ids.size == 1 && ids.first.is_a?(Enumerable)
aaf_index.bulk_index(ids)
end
aaf_index is an instance of RemoteIndex that dispatches bulk_index to
the drb server, correct? If that’s the case, then the Server class
sends the method call to the aaf_index, which has bulk_index defined
in ferret_extensions.rb, correct? the bulk_index method uses the
BulkIndexer.index_records method, which checks to see if ferret is
enbled for each record: rec.ferret_enabled?(true). Now, if this all
happens in the Drb server, wouldn’t ferret be disabled there as it is
obviously using the same environment.rb file that disables ferret for
MyModel?
Thanks in advance.
On Thu, Oct 04, 2007 at 11:56:36AM -0400, Erik M. wrote:
Now, ClassMethods defines bulk_index as:
BulkIndexer.index_records method, which checks to see if ferret is
enbled for each record: rec.ferret_enabled?(true). Now, if this all
happens in the Drb server, wouldn’t ferret be disabled there as it is
obviously using the same environment.rb file that disables ferret for
MyModel?
Exactly. Since with bulk_index (and rebuild_index, too) the
ferret_enabled? check always only happens in the DRb server, calling
MyModel.enable_ferret on the client side has no effect.
I just fixed this - instance.ferret_enabled? now ignores the
class level ferret_enabled state when called by the bulk indexer (which
is also used by the rebuild_index method, so the same behaviour applies
there).
I think the behaviour now is more useful - when you disable ferret at
the class level and then explicitly call bulk_index or rebuild_index on
this class, aaf assumes you have a good reason to do so and just does
what you say.
Cheers,
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