Forum: Ferret keeping items out of the index AAF

A99ccfa84810c6016a9d3dc3429a2e00?d=identicon&s=25 Tony Primerano (primerano)
on 2009-10-22 17:20
I've seen this question asked a few times but I haven't seen an answer.

I'm using the AAF plugin in my rails app and I have a flag on my model
that indicates if an item is to be indexed.  I then access this flag via
the acts_as_ferret call.

:if => Proc.new { |domain| domain.do_index?}

all do_index? does is look at a boolean at the moment
  def do_index?
    self.available
  end

My AAF line is
acts_as_ferret(:if => Proc.new { |domain| domain.do_index?}, :remote =>
true, :fields =>{:name => {:store => :yes, :boost => 2},, :search_terms
=> {:store => :yes, :boost => 1.5}, :keywords => {:store => :yes }},
:ferret => {:analyzer => StemmedAnalyzer.new})

Everything in the model gets indexed, regardless of the flag setting.

I am using DRb.  I haven't restarted the server but I have called
rebuild_index on my model and watched items with available=false get
indexed.
A99ccfa84810c6016a9d3dc3429a2e00?d=identicon&s=25 Tony Primerano (primerano)
on 2009-10-22 17:45
As usual I found part of my answer within minutes of posting.

I like to think of the ferret_server as a passive object that just does
what it is told but it looks like it looks at the application
configuration.  When I restarted it it stopped indexing items that I
marked as unavailable BUT...

how do I get it to remove an object?

If I set an object to available it shows up fine but when I set
available=false it just isn't indexed.   This is fine but I need it
removed from the index.

Help?  :-)
A99ccfa84810c6016a9d3dc3429a2e00?d=identicon&s=25 Tony Primerano (primerano)
on 2009-10-22 18:02
> If I set an object to available it shows up fine but when I set
> available=false it just isn't indexed.   This is fine but I need it
> removed from the index.
>


My fix for this is in my model I added

  after_save :ping_indexer

  def ping_indexer
    if !available
      ferret_destroy
    end
  end
This topic is locked and can not be replied to.