ASF: cannot determine document number from primary key

I’m getting this exception from acts_as_ferret:

A RuntimeError occurred in search#similar:

cannot determine document number from primary key:
#MyClass:0x9feba20
[RAILS_ROOT]/vendor/plugins/acts_as_ferret/lib/instance_methods.rb:132:in
`document_number’

As a result of this call:

object.more_like_this

The relevant backtrace:

[RAILS_ROOT]/vendor/plugins/acts_as_ferret/lib/instance_methods.rb:132:in
document_number' [RAILS_ROOT]/vendor/plugins/acts_as_ferret/lib/more_like_this.rb:64:inmore_like_this’
/usr/local/lib/ruby/1.8/monitor.rb:229:in synchronize' [RAILS_ROOT]/vendor/plugins/acts_as_ferret/lib/more_like_this.rb:61:inmore_like_this’
[RAILS_ROOT]/app/controllers/search_controller.rb:52:in `similar’

I’ve played with this for hours and can’t seem to track it down. My
best guess is a corrupt index. Does that sound about right?

BTW, I’m on trunk, revision 118.

It’s a strange error because it up until last night, I never saw it in
production, only in development. Now I’m getting exception notification
emails from production.

I just got this same error yesterday. I determined it was because my id
field was set to be tokenized. Once I turned off tokenization this
problem went away. I must also mention that I use a modified version of
AAF that allows id to be a string instead. I only receieved this error
when using search by similar results and when searching for an id that
had a letter in it. If the query had only numbers in it, I would not
recieve this error. Kinda strange…
Anyhow, as I said above, the solution for me was to make id untokenized
again (not a big deal, although I would of preferred it to be
tokenized).

Hope that helps,
Ray

Does AAF use object.id to get the id, or object.to_param? I have a few
models that override to_param to return something like “25-FooBar”, but
id still returns 25.

On Fri, Jan 12, 2007 at 12:18:24AM +0100, Raymond O’connor wrote:

I just got this same error yesterday. I determined it was because my id
field was set to be tokenized. Once I turned off tokenization this
problem went away. I must also mention that I use a modified version of
AAF that allows id to be a string instead. I only receieved this error
when using search by similar results and when searching for an id that
had a letter in it. If the query had only numbers in it, I would not
recieve this error. Kinda strange…
Anyhow, as I said above, the solution for me was to make id untokenized
again (not a big deal, although I would of preferred it to be
tokenized).

the id field is meant to be a unique key identifying a single record. It
should not be tokenized in any case. If you need to run searches on it,
you should consider adding an additional tokenized field to the index
containing the same value.

Jens


webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer [email protected]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66

On Fri, Jan 12, 2007 at 12:47:32AM +0100, Peter J. wrote:

Does AAF use object.id to get the id, or object.to_param? I have a few
models that override to_param to return something like “25-FooBar”, but
id still returns 25.

aaf uses self.id to determine the value that goes into the :id field of
the ferret index. see to_doc in instance_methods.rb .

cheers,
Jens


webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer [email protected]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66

On Thu, Jan 11, 2007 at 05:00:33PM +0100, Peter J. wrote:

object.more_like_this

The relevant backtrace:

[RAILS_ROOT]/vendor/plugins/acts_as_ferret/lib/instance_methods.rb:132:in
`document_number’

the query to retrieve the document number is built in query_for_self
(also in instance_methods.rb). You could insert some debugging code to
output that query and check if it looks right (e.g. by running it
manually against your index). It should return exactly one hit, matching
the record you’re calling more_like_this on.

Jens


webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer [email protected]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs