# Acts\_as\_ferret searching id

**URL:** <https://www.ruby-forum.com/t/acts-as-ferret-searching-id/131231>\
**Category:** Rails\
**Created:** [March 7, 2008, 3:06am UTC](https://www.ruby-forum.com/t/acts-as-ferret-searching-id/131231 "2008-03-07T03:06:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfaulkenberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c2a13f/32.png) [@jfaulkenberry](https://www.ruby-forum.com/u/jfaulkenberry)\
**Post date:** [March 7, 2008, 3:06am UTC](https://www.ruby-forum.com/t/acts-as-ferret-searching-id/131231/1 "2008-03-07T03:06:03Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![jfaulkenberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c2a13f/32.png) [@jfaulkenberry](https://www.ruby-forum.com/u/jfaulkenberry)\
**Post date:** [March 7, 2008, 10:38am UTC](https://www.ruby-forum.com/t/acts-as-ferret-searching-id/131231/2 "2008-03-07T10:38:51Z")

</div>

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:’)

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

–  
Jens W., Dipl.-Bibl. (FH)  
prometheus - Das verteilte digitale Bildarchiv für Forschung & Lehre  
Kunsthistorisches Institut der Universität zu  
KölnAlbertus-Magnus-Platz, D-50923  
KölnTel.: +49 (0)221 470-6668, E-Mail: removed\_email\_address@domain.invalid  
[http://www.prometheus-bildarchiv.de/](http://www.prometheus-bildarchiv.de/)

---

<div class="post-metadata">

**Author:** ![jfaulkenberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c2a13f/32.png) [@jfaulkenberry](https://www.ruby-forum.com/u/jfaulkenberry)\
**Post date:** [March 7, 2008, 11:07pm UTC](https://www.ruby-forum.com/t/acts-as-ferret-searching-id/131231/3 "2008-03-07T23:07:37Z")

</div>

Jonathan F. [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 , :ferret =\> { :default\_field =\>  
 }

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](http://projects.jkraemer.net/rdoc/acts_as_ferret/classes/ActsAsFerret/ActMethods.html#M000009)

cheers  
jens

---

<div class="post-metadata">

**Author:** ![jfaulkenberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c2a13f/32.png) [@jfaulkenberry](https://www.ruby-forum.com/u/jfaulkenberry)\
**Post date:** [March 7, 2008, 8:47pm UTC](https://www.ruby-forum.com/t/acts-as-ferret-searching-id/131231/4 "2008-03-07T20:47:29Z")

</div>

hi jonzo!

Hi! 🙂

> worksforme:
> 
> find\_with\_ferret(‘id:’)
> 
> 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 🙂
