views:

395

answers:

2

I am doing a very simple search on my DB using acts_as_ferret. I put this in my "Venue" model:

acts_as_ferret :fields => [:name, :city]

And this is in my controller search action:

@t = Venue.find_by_contents(params[:search]+'~')

and then I just render the results.

render :text => @t.to_json, :success => true, :status => :ok

If I run a quick test:

http://localhost:3000/venue/list?search=The

I see in my log that the proper query "The~" is being executed on the index. However, I get no results. I definitely have a few "Venues" with the word "The" in the name field.

Since this is a very simple search and acts_as_ferret is used quite a bit, I tried rebuilding the index to see if it was corrupted....no dice

Any ideas?

Thanks!

+2  A: 

Yes, Ferret has been very well known for corrupting indexes.

I recommend switching over to another searching plugin like Thinking Sphinx. You can watch the Railscast about it in order to learn more.

Ryan Bigg
Agreed - avoid AAF. There are better options out there: ThinkingSphinx and even Solr if you need everything that Lucene provides
Patrick Reagan
+1  A: 

I think the problem might be that "the" is defined as a stopword- an extremely common word that is not indexed because it would just return every document. You can configure your stopword list.

I would consider using Solr if you are having problems with Ferret.

MattMcKnight
ended up with TS but thanks for the insight!
Tony