How to update index with acts_as_ferret?

Hey all,
I have movie has_many :medias and media belongs_to :media

this is how my movie class looks like:

class Movie < ActiveRecord::Base
has_many :medias

acts_as_ferret :fields => [:title,:medias_name]

def medias_name
return self.medias.inject("") {|name,m| name + " " + m.name}
end

end

when I do Movie.find_by_contents(“title:bob”) it does return a movie
and if I modify that movie title to Bill and do
Movie.find_by_contents(“title:bill”) it will return the movie also.

But if I create a new media xyz and try to search on it
Movie.find_by_contents(“medias_name:xyz”) it doesn’t find it, I need
to rm -rf index/ and restart the server to make it find it. Any idea
how I can update the index on special fields?

thanx in advance

Pat

Hi!

On Fri, May 25, 2007 at 04:27:35AM +0200, Patrick A. wrote:

def medias_name
Movie.find_by_contents(“medias_name:xyz”) it doesn’t find it, I need
to rm -rf index/ and restart the server to make it find it. Any idea
how I can update the index on special fields?

you can’t update single fields, you havbe to reindex that movie to
reflect the changes. An after_save hook in media calling
movie.ferret_update should do the trick.

Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs