> From: Jens Kraemer <jk at jkraemer.net> > Subject: Re: [Ferret-talk] Performance before and after optimization> On Sat, Nov 03, 2007 at 08:49:17PM +0800, Alex Neth wrote: > [..] >> 2) Can I keep a second index so that it doesn''t get locked during >> optimization and then switch to the optimized index? Perhaps the >> index >> is not really locked and it is just using all the CPU? (I am using a >> single CPU server)? > > If you''re already indexing in batches, keeping a second read-only > index for > searching is a good idea. rsync is useful to keep the search-index > up to > date in this case. > > To check if CPU usage is a problem, try lowering the optimizing > process'' > priority and see how it goes. >Thanks Jens. Any suggestion on how to get a two index solution working with acts_as_ferret? I could not find an easy way to change the index location dynamically. I would love to have a "read-only" index. It seems like using rsync might be problematic though as the index might not be in a consistent state throughout the sync. I don''t think it is CPU, but it is definitely locking my site for up to a minute during optimization, which is very bad.
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
> 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?On 11/7/07, Stuart Sierra <mail at stuartsierra.com> wrote:> I rolled my own with methods in my model class, something like this:Correction: this line:> start.step(max, increment) do |n|should be> start.upto(max) do |n|-Stuart Sierra columbialawtech.org