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, ferret-talk-request at rubyforge.org wrote:
>
> Message: 7
> Date: Wed, 7 Nov 2007 17:01:45 -0500
> From: "Stuart Sierra" <mail at stuartsierra.com>
> Subject: Re: [Ferret-talk] Ferret-talk Digest, Vol 25, Issue 2
> To: ferret-talk at rubyforge.org
> Message-ID:
> <314ee0450711071401l97b4be8j5e298d7d24383ea3 at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On 11/7/07, Alex Neth <alex at liivid.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/ferret-talk/attachments/20071110/7106628d/attachment.html