acts_as_ferret searching id

Hi there,

I'm using acts_as_ferret, and I'd like to search by ID. Apparently aaf automatically adds id to the search index, and I noticed that if you try to manually add it you get an error, but if I search by ID it doesn't find anything... Does anyone know how to tell aaf that I want to search by id as well? I can't find it in the docs anywhere...

hi jonzo!

Jonzo [2008-03-07 03:05]:

I'm using acts_as_ferret, and I'd like to search by ID. Apparently aaf automatically adds id to the search index, and I noticed that if you try to manually add it you get an error, but if I search by ID it doesn't find anything... Does anyone know how to tell aaf that I want to search by id as well? I can't find it in the docs anywhere...

worksforme:

  find_with_ferret('id:<your-id-here>')

note that ID isn't part of the default field list, so you have to specify it explicitly. OTOH, are you sure you're searching for an ID that's actually present in the index?

hth jens

hi jonzo!

Hi! :slight_smile:

worksforme:

  find_with_ferret('id:<your-id-here>')

note that ID isn't part of the default field list, so you have to specify it explicitly.

Is there any way I can make it part of the default field list? I don't want to start screwing with peoples queries, I started doing that a while ago and ended up adding lots of stuff to make ferret behave how I thought I wanted it to behave... but it ends up getting really confusing so I reverted back to basics (not touching the query, then manipulating the results afterwards)

OTOH, are you sure you're searching for an ID

that's actually present in the index?

Yeah :slight_smile:

Jonathan Fantham [2008-03-07 20:46]:

Is there any way I can make it part of the default field list?

well, you can add it in your acts_as_ferret call (untested):

  acts_as_ferret <your-options>, :ferret => { :default_field => <array-of-fields-incl-id> }

see the documentation at [1]. but please notice the warning about including untokenized fields in the default_field list, since :id *is* untokenized.

[1] <http://projects.jkraemer.net/rdoc/acts_as_ferret/classes/ActsAsFerret/ActMethods.html#M000009&gt;

cheers jens