Peter Jones
2007-Jan-11 16:00 UTC
[Ferret-talk] 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:in `more_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:in `more_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. -- Posted via http://www.ruby-forum.com/.
Raymond O''connor
2007-Jan-11 23:18 UTC
[Ferret-talk] ASF: cannot determine document number from primary key
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 -- Posted via http://www.ruby-forum.com/.
Peter Jones
2007-Jan-11 23:47 UTC
[Ferret-talk] ASF: cannot determine document number from primary key
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. -- Posted via http://www.ruby-forum.com/.
Jens Kraemer
2007-Jan-12 10:05 UTC
[Ferret-talk] ASF: cannot determine document number from primary key
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 kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
Jens Kraemer
2007-Jan-12 10:07 UTC
[Ferret-talk] ASF: cannot determine document number from primary key
On Fri, Jan 12, 2007 at 12:47:32AM +0100, Peter Jones 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 kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66
Jens Kraemer
2007-Jan-12 10:10 UTC
[Ferret-talk] ASF: cannot determine document number from primary key
On Thu, Jan 11, 2007 at 05:00:33PM +0100, Peter Jones wrote:> 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''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 kraemer at webit.de Schnorrstra?e 76 Tel +49 351 46766 0 D-01069 Dresden Fax +49 351 46766 66