# Backgroundrb and ferret

**URL:** <https://www.ruby-forum.com/t/backgroundrb-and-ferret/75542>\
**Category:** Ferret\
**Created:** [November 10, 2006, 8:13pm UTC](https://www.ruby-forum.com/t/backgroundrb-and-ferret/75542 "2006-11-10T20:13:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caspar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9bcb4/32.png) [@Caspar](https://www.ruby-forum.com/u/Caspar)\
**Post date:** [November 10, 2006, 8:13pm UTC](https://www.ruby-forum.com/t/backgroundrb-and-ferret/75542/1 "2006-11-10T20:13:40Z")

</div>

Hi I’m using ferret happily on a site with 260ish documents in the  
index. Problem is that the site is still in development and I have to  
rebuild the index fairly regularly as new fields are added to it, like  
today when i added price. I have been using a rebuild index action in  
the admin section but this is clearly the wrong way to do it as it  
completly kills the site during the rebuild. So question is how do  
people handle index rebuilds on sites with large indexes and keep them  
live? I have come accross backgroundrb and think this is the way to go  
but am unsure about some things. E.g. if you have backgroundrb  
rebuilding the index, what happens in the meantime with the old index?  
Is it still accessable while the index is rebuilt? What happens if  
someone adds a new record during the index getting rebuilt? Id anyone  
has experience using backgroundrb and ferret then i would really  
appreciate your comments or code.  
Thanks very much  
caspar

---

<div class="post-metadata">

**Author:** ![Caspar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9bcb4/32.png) [@Caspar](https://www.ruby-forum.com/u/Caspar)\
**Post date:** [November 10, 2006, 8:14pm UTC](https://www.ruby-forum.com/t/backgroundrb-and-ferret/75542/2 "2006-11-10T20:14:27Z")

</div>

Caspar wrote:

> Hi I’m using ferret happily on a site with 260ish documents in the

should have been 260 000ish…

---

<div class="post-metadata">

**Author:** ![Caspar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e9bcb4/32.png) [@Caspar](https://www.ruby-forum.com/u/Caspar)\
**Post date:** [November 13, 2006, 10:02am UTC](https://www.ruby-forum.com/t/backgroundrb-and-ferret/75542/3 "2006-11-13T10:02:21Z")

</div>

On Fri, Nov 10, 2006 at 08:13:40PM +0100, Caspar wrote:

> Is it still accessable while the index is rebuilt?  
> If you open up a searcher on the old index before you start rebuilding,  
> that searcher should be able to search the old index while the rebuild  
> runs.

Another way is to create a whole new index, and just swap indexes once  
you’re finished rebuilding.

> What happens if someone adds a new record during the index getting  
> rebuilt?

It’s up to you to keep track of these changes, i.e. with a db flag  
telling you if this record needs indexing or not. Once you have such a  
flag, you could do all your indexing in a backgroundrb job regularly,  
i.e. check every 10 minutes for records to be indexed, and index them.

Jens

–  
webit! Gesellschaft für neue Medien mbH [www.webit.de](http://www.webit.de)  
Dipl.-Wirtschaftsingenieur Jens Krämer removed\_email\_address@domain.invalid  
Schnorrstraße 76 Tel +49 351 46766 0  
D-01069 Dresden Fax +49 351 46766 66
