# Disable search match on model id

**URL:** <https://www.ruby-forum.com/t/disable-search-match-on-model-id/83182>\
**Category:** Ferret\
**Created:** [January 24, 2007, 4:13am UTC](https://www.ruby-forum.com/t/disable-search-match-on-model-id/83182 "2007-01-24T04:13:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![reynar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e99b99/32.png) [@reynar](https://www.ruby-forum.com/u/reynar)\
**Post date:** [January 24, 2007, 4:13am UTC](https://www.ruby-forum.com/t/disable-search-match-on-model-id/83182/1 "2007-01-24T04:13:11Z")

</div>

Hi,

Given a numerical search term I want to avoid matching the model id as  
this has no real world significance when returned in the results (in  
this instance).

For example the user may enter ‘13’ when looking for a product code.  
Presently they will also get back the product that has id 13.

I have tried:

acts\_as\_ferret :fields =\> {:id =\> { :index =\> :no }, :description =\> {},  
:manufacturer\_code =\> {}}

However this fails with “You can’t store the term vectors of an  
unindexed field”.

As the id is likely a special case do I need to instead limit the search  
somehow when calling the find\_by\_contents method? Presently I simply  
have:

@products = Product.find\_by\_contents(@phrase, :num\_docs =\> 200)

Any advice much appreciated.

Andrew.

---

<div class="post-metadata">

**Author:** ![reynar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e99b99/32.png) [@reynar](https://www.ruby-forum.com/u/reynar)\
**Post date:** [January 24, 2007, 10:28am UTC](https://www.ruby-forum.com/t/disable-search-match-on-model-id/83182/2 "2007-01-24T10:28:03Z")

</div>

On Wed, Jan 24, 2007 at 04:13:11AM +0100, Andrew E. wrote:

> Hi,
> 
> Given a numerical search term I want to avoid matching the model id as  
> this has no real world significance when returned in the results (in  
> this instance).
> 
> For example the user may enter ‘13’ when looking for a product code.  
> Presently they will also get back the product that has id 13.

what version of aaf do you use? the id is not supposed to be included in  
queries, however it might be that this is the case in older versions.

[…]

> acts\_as\_ferret :fields =\> {:id =\> { :index =\> :no }, :description =\> {},  
> :manufacturer\_code =\> {}}
> 
> However this fails with “You can’t store the term vectors of an  
> unindexed field”.

I don’t know if not indexing the id would be a good idea, since it is  
used as a key field and needed for updates (delete old document by id,  
add new one).

Jens

–  
webit! Gesellschaft für neue Medien mbH [www.webit.de](http://www.webit.de)  
Dipl.-Wirtschaftsingenieur Jens Krämer removed\_email\_address@domain.invalid  
Schnorrstraße 76 Tel +49 351 46766 0  
D-01069 Dresden Fax +49 351 46766 66

---

<div class="post-metadata">

**Author:** ![reynar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e99b99/32.png) [@reynar](https://www.ruby-forum.com/u/reynar)\
**Post date:** [January 24, 2007, 1:59pm UTC](https://www.ruby-forum.com/t/disable-search-match-on-model-id/83182/3 "2007-01-24T13:59:03Z")

</div>

Thanks, I have just updated the project plugin to the trunk version. It  
now works as described.

I think I might of had some confusion over project plugin and system gem  
versions. Either way it is now resolved. Thanks again.

Andrew.
