Forum: Ferret Disable search match on model id

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andrew E. (Guest)
on 2007-01-24 05:13
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.
Jens K. (Guest)
on 2007-01-24 11:28
(Received via mailing list)
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
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
Andrew E. (Guest)
on 2007-01-24 14:59
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.
This topic is locked and can not be replied to.