# Update each record in order to update Ferret index?

**URL:** <https://www.ruby-forum.com/t/update-each-record-in-order-to-update-ferret-index/149497>\
**Category:** Rails\
**Created:** [September 25, 2008, 1:30pm UTC](https://www.ruby-forum.com/t/update-each-record-in-order-to-update-ferret-index/149497 "2008-09-25T13:30:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [September 25, 2008, 1:30pm UTC](https://www.ruby-forum.com/t/update-each-record-in-order-to-update-ferret-index/149497/1 "2008-09-25T13:30:30Z")

</div>

Hi,

I’m having some problems on a particular acts\_as\_ferret model.  
Rebuilding the index with Model.rebuild\_index does not seem to work. No  
results are returned after indexing. However,  
when I update each record manually, the index seems to be correct.

This is my model:

class Article \< ActiveRecord::Base

…  
acts\_as\_articlequerybuilder  
acts\_as\_messageuser :Article,:title,:body,:excerpt  
acts\_as\_ferret :fields =\> [ :active\_title,:active\_excerpt,:joined\_tags  
], :remote =\> true

…

end

The fields specified are custom methods, defined in acts\_as\_messageuser.  
Maby this is causing some troubles with ferret :

```
    #active_title => returns title field in current active language
    define_method('active_'+param.to_s) do
       value = read_attribute(param.to_s)
       language = $activelanguage.code.to_sym
       if value
         Message.find(value).send(language)
       else
         nil
       end
    end

```

Can somebody point me in the right direction? Oh, I’m using  
ferret\_server in production mode. Ferret works fine on the model in  
development mode without ferret\_server

Thanks

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [September 25, 2008, 1:45pm UTC](https://www.ruby-forum.com/t/update-each-record-in-order-to-update-ferret-index/149497/2 "2008-09-25T13:45:02Z")

</div>

no real help for your actual problem.

But we moved an existing project from ferret to sphinx,  
for exactly the reasons you mention. Everything working  
fine in dev, but fails in prod.  
If you google around a bit, you’ll find that this seems a common  
problem with ferret.

I would recommend moving to sphinx. Depending on amount of  
models that use ferret, this shouldn’t take more than a day or two.

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [September 25, 2008, 2:26pm UTC](https://www.ruby-forum.com/t/update-each-record-in-order-to-update-ferret-index/149497/3 "2008-09-25T14:26:57Z")

</div>

On Thu, Sep 25, 2008 at 4:30 AM, Maarten P. \<  
removed\_email\_address@domain.invalid\> wrote:

> class Article \< ActiveRecord::Base
> 
> ```
> nil
> end
> end
> 
> ```
> 
> Can somebody point me in the right direction? Oh, I’m using  
> ferret\_server in production mode. Ferret works fine on the model in  
> development mode without ferret\_server

Hi, could you tell us about the actual configuration of ferret? How’s  
Ferret  
working in development mode without the ferret\_server? Is the  
ferret\_server  
up and operational in the production environment?

-Conrad

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [September 25, 2008, 3:19pm UTC](https://www.ruby-forum.com/t/update-each-record-in-order-to-update-ferret-index/149497/4 "2008-09-25T15:19:45Z")

</div>

> Hi, could you tell us about the actual configuration of ferret? How’s  
> Ferret  
> working in development mode without the ferret\_server? Is the  
> ferret\_server  
> up and operational in the production environment?
> 
> -Conrad

Hi Conrad,

In development mode, I’m just using the local index without any ferret  
server. In production mode, the ferret server is definitely doing it’s  
job. Most models using ferret, are simple models with straightforward  
fields. However, the article model is a bit more complex and doesn’t  
index unless I update each record manually.

here is my server config:

development:  
host: localhost  
port: 9015  
pid\_file: log/ferret.pid  
log\_file: log/ferret\_server.log

Hmm … If I can’t fix it, I have two options:

- Iterate trough all articles and update manually once in a while
- try out to Sphinx

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [September 27, 2008, 12:55pm UTC](https://www.ruby-forum.com/t/update-each-record-in-order-to-update-ferret-index/149497/5 "2008-09-27T12:55:26Z")

</div>

Maarten P. wrote:

> acts\_as\_articlequerybuilder  
> development mode without ferret\_server  
> Give this a go:

class Article  
acts\_as\_ferret :fields =\> […]  
cattr\_accessor :ferret\_server  
self.ferret\_server = ActsAsFerret.remote? ? aaf\_index : self  
end

Article.ferret\_server.rebuild\_index

–  
Rails Wheels - Find Plugins, List & Sell Plugins -  
[http://railswheels.com](http://railswheels.com)
