# Keeping items out of the index AAF

**URL:** <https://www.ruby-forum.com/t/keeping-items-out-of-the-index-aaf/177718>\
**Category:** Ferret\
**Created:** [October 22, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/keeping-items-out-of-the-index-aaf/177718 "2009-10-22T17:20:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tnyplz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@tnyplz](https://www.ruby-forum.com/u/tnyplz)\
**Post date:** [October 22, 2009, 5:20pm UTC](https://www.ruby-forum.com/t/keeping-items-out-of-the-index-aaf/177718/1 "2009-10-22T17:20:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tnyplz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@tnyplz](https://www.ruby-forum.com/u/tnyplz)\
**Post date:** [October 22, 2009, 5:45pm UTC](https://www.ruby-forum.com/t/keeping-items-out-of-the-index-aaf/177718/2 "2009-10-22T17:45:54Z")

</div>

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? 🙂

---

<div class="post-metadata">

**Author:** ![tnyplz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@tnyplz](https://www.ruby-forum.com/u/tnyplz)\
**Post date:** [October 22, 2009, 6:02pm UTC](https://www.ruby-forum.com/t/keeping-items-out-of-the-index-aaf/177718/3 "2009-10-22T18:02:16Z")

</div>

> 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
