Problems with Ferret and acts_as_ferret

Hi all,

I'm trying to set up Ferret with the acts_as_ferret plugin and have
run into some problems. I'm using a very basic setup as recommended by
all the tutorials: install the ferret gem and acts_as_ferret plugin,
put the line acts_as_ferret in my User class, then do something like
this in my controller:

@users = User.find_with_ferret(params[:query])

This returns no results. The log shows no errors, just something like:

Query: test
total hits: 0, results delivered: 0

No results are found for any query. I've tried deleting the Index
directory and restarting the server, but this doesn't help. I wonder
if this is related to the fact that much of the documentation seems to
be out of date - almost all tutorials refer to find_by_contents, which
I believe has been replaced by find_with_ferret. Also, I installed the
acts_as_ferret gem and ran aaf_install - could this have caused
problems? Has anyone successfully got this to work?

Many thanks,
Adam

It works fine for me.
maybe force a rebuild index in script/console:
Model.rebuild_index

and use @object.ferret_update whenever you change something in a field
that's ferret indexed.

otherwise have a look at acts_at_ferret.log in the log folder...

Thanks for the quick reply. There's definately a problem with the
indexing. In acts_as_ferret.log I'm repeatedly getting

[user] register class User with index user
[user] refusing re-registration of class User

Also, in the index directory, the file segments is empty, and
segments_0 contains only the line

class_name?

I tried using User.rebuild_index from the console and it did appear to
build an index - there are now files called segments_oj and _oi.cfs in
the index directory which are not empty. However, User.find_by_ferret
still returns no results. I'm pretty stumped!

I don't have much of an idea, since it worked for me easy enough.
maybe you didn't set it up properly?

acts_as_ferret :fields => {:name => {:boost => 3}, :description =>
{:boost => 2, :store => :no}, :tag_list => {}},
                 :index_dir => File.join(RAILS_ROOT, "public",
"index")

this one is adding fields name and description
plus the tag_list (from acts_as_taggable)
but as you see, it's not doing much. the boos values are optional
anyway

Fixed! Looks like it was just a dodgy installation. I was using the
plugin installer built in to Aptana Radrails, which I guess must be
corrupt. When I removed it and did a manual install it worked fine.

Thanks for your help :slight_smile: