Keeping items out of the index AAF


#1

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.


#2

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? :slight_smile:


#3

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