Hi Carl,
I actually finished integrating my cFerret indexer but I''m not going
to release it. The performance is great but the code is really messy
and it would be a nightmare to maintain. Instead I''m porting the
search part of Lucene to C and I''ll write a Ruby interface to this
when I''m finished. I wish I could give you an accurate estimate but
the search module is the largest part or Lucene so it''s going to take
time. As an added bonus, search will be a lot faster as well as
indexing so it will be worth the wait. Hopefully I''ll have something
finished by Christmas.
Solution: instead of optimizing your index every time you change it,
just flush it. This will keep your ActiveRecord model is in sync with
your index without the large delay.
Cheers,
Dave
On 12/2/05, Carl Youngblood <carl at youngbloods.org>
wrote:> I''m noticing some long delays when optimizing my index. I know
this
> is terribly inefficient, but in order to make sure that my
> ActiveRecord model is in sync with my index, I''m optimizing after
> every new record that I store, like so:
>
> class Resume < ActiveRecord::Base
> include Ferret
> has_and_belongs_to_many :users
> SEARCH_INDEX = File.dirname(__FILE__) +
''/../../searchindex''
>
> # syncronization with ferret index
> def after_save
> @@index ||= Index::Index.new(:path => SEARCH_INDEX,
> :create_if_missing => true)
> @@index << {:id => id, :email => email, :contents =>
contents,
> :date => found_on}
> @@index.flush
> @@index.optimize
> end
>
> def after_destroy
> @@index ||= Index::Index.new(:path => SEARCH_INDEX,
> :create_if_missing => true)
> @@index.delete(id)
> @@index.flush
> @@index.optimize
> end
>
> ...
> end
>
> I''m noticing about a 2-3 second delay after every new record that
I
> store. I''m thinking that this will be bearable when cFerret comes
> out. Do you have any estimate on when that might be?
>
> Thanks,
> Carl
>
> _______________________________________________
> Ferret-talk mailing list
> Ferret-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ferret-talk
>