Thanks Stuart. I thought I had read somewhere that rebuild_index
built the index in a different location and then swapped it, but
after looking at the code (in local_index.rb) this doesn't appear to
be the case. That might explain why the ferret server crashes
sometimes when a search takes place during a reindex.
I wouldn't be doing exactly the same thing as this but this does get
me started. I'm concerned about swapping the index files on a live
site though. Seems risky so I'll probably try to update the
ferret_index member in LocalIndex. Looks like that will work.
-Alex
On Nov 10, 2007, at 4:36 PM, [EMAIL PROTECTED] wrote:
Message: 7
Date: Wed, 7 Nov 2007 17:01:45 -0500
From: "Stuart Sierra" <[EMAIL PROTECTED]>
Subject: Re: [Ferret-talk] Ferret-talk Digest, Vol 25, Issue 2
To: [email protected]
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=UTF-8
On 11/7/07, Alex Neth <[EMAIL PROTECTED]> wrote:
Thanks Jens. Any suggestion on how to get a two index solution
working with acts_as_ferret?
I rolled my own with methods in my model class, something like this:
def self.setup_new_index(location)
config = aaf_configuration[:ferret].dup
config.update(:create => true, :auto_flush => false,
:field_infos => ActsAsFerret::field_infos([self]),
:path => location)
index = Ferret::Index::Index.new(config)
index.logger = Logger.new("#{location}/index.log")
index
end
def self.build_new_index(location)
index = setup_new_index(location)
max = self.maximum(:id)
start = self.minimum(:id)
start.step(max, increment) do |n|
begin
record = self.find(n)
rescue ActiveRecord::RecordNotFound
next
end
index << record.to_doc if record and record.ferret_enabled?
(true)
end
end
Then I have a rake task to replace the old index with the new one.
-Stuart Sierra
columbialawtech.org
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk