Cannot automatically map attribute sphinx_internal_id

129 views
Skip to first unread message

Sebastian

unread,
Oct 12, 2010, 6:15:36 PM10/12/10
to Thinking Sphinx
Using: Rails 3 and Ruby-1.9.2 on OSX Snow Leopard 32

I've installed several different versions of Sphinx (0.9.8, 0.9.9) and
Thinking Sphinx (2.0.0.rc1, 2.0.0.rc2) and keep getting this error on
"rake thinking_sphinx:index"

I've followed the instructions for installing Sphinx and Thinking
Sphinx with Rails3 here (http://freelancing-god.github.com/ts/en/
rails3.html)...

An here's the model that I'm trying this on:

class MainFoodDesc < ActiveRecord::Base
define_index do
indexes maindescription
end
end

I'm at my wit's end trying to figure this out. Anyone got any advice?

Pat Allan

unread,
Oct 12, 2010, 6:23:49 PM10/12/10
to thinkin...@googlegroups.com
Hi Sebastian

Can you give us the full error output - is there a stack trace, or a pointer to a line in your development.sphinx.conf?

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
>

Sebastian

unread,
Oct 12, 2010, 9:06:45 PM10/12/10
to Thinking Sphinx
Hi Pat, thanks for the reply.

Here's the full trace:

** Invoke thinking_sphinx:index (first_time)
** Invoke thinking_sphinx:app_env (first_time)
** Execute thinking_sphinx:app_env
** Invoke environment (first_time)
** Execute environment
** Execute thinking_sphinx:index
Generating Configuration to /Users/Sebastian/Sites/tracker/config/
development.sphinx.conf
rake aborted!

Cannot automatically map attribute sphinx_internal_id in MainFoodDesc
to an
equivalent Sphinx type (integer, float, boolean, datetime, string as
ordinal).
You could try to explicitly convert the column's value in your
define_index
block:
has "CAST(column AS INT)", :type => :integer, :as => :column
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/attribute.rb:326:in
`translated_type_from_database'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/attribute.rb:162:in `type'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/attribute.rb:127:in
`type_to_config'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/source.rb:98:in `block in
set_source_attributes'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/source.rb:97:in `each'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/source.rb:97:in
`set_source_attributes'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/source.rb:48:in
`to_riddle_for_core'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/index.rb:114:in `block in
to_riddle_for_core'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/index.rb:113:in `each'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/index.rb:113:in `each_with_index'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/index.rb:113:in
`to_riddle_for_core'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/index.rb:83:in `to_riddle'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/active_record.rb:223:in `block in
to_riddle'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/active_record.rb:222:in `collect'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/active_record.rb:222:in
`to_riddle'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/configuration.rb:154:in `block in
build'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/configuration.rb:151:in `each'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/configuration.rb:151:in `build'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/thinking-
sphinx-2.0.0.rc2/lib/thinking_sphinx/tasks.rb:69:in `block (2 levels)
in <top (required)>'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
636:in `call'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
636:in `block in execute'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
631:in `each'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
631:in `execute'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
597:in `block in invoke_with_call_chain'
/Users/Sebastian/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/monitor.rb:
201:in `mon_synchronize'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
590:in `invoke_with_call_chain'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
583:in `invoke'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
2051:in `invoke_task'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
2029:in `block (2 levels) in top_level'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
2029:in `each'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
2029:in `block in top_level'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
2068:in `standard_exception_handling'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
2023:in `top_level'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
2001:in `block in run'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
2068:in `standard_exception_handling'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/rake.rb:
1998:in `run'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/bin/rake:
31:in `<top (required)>'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `load'
/Users/Sebastian/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `<main>'

Cheers
SB



On Oct 12, 6:23 pm, Pat Allan <p...@freelancing-gods.com> wrote:
> Hi Sebastian
>
> Can you give us the full error output - is there a stack trace, or a pointer to a line in your development.sphinx.conf?
>
> --
> Pat
>

Pat Allan

unread,
Oct 12, 2010, 9:09:20 PM10/12/10
to thinkin...@googlegroups.com
Ah, right. Are you using non-integer primary keys?

--
Pat

Sebastian

unread,
Oct 12, 2010, 9:33:51 PM10/12/10
to Thinking Sphinx
No. The table columns/types are:

foodcode (primary key, int)
startdate (date)
enddate (date)
maindescription (varchar 200)
abbrdescription (varchar 60)

So the primary key is an integer, but it isn't 1-->N
autoincrementing ... It's unique food codes set by the USDA.

Could that be the issue?

Pat Allan

unread,
Oct 12, 2010, 10:26:24 PM10/12/10
to thinkin...@googlegroups.com
Hmm, right. What does your MainFoodDesc model code look like?

--
Pat

Sebastian

unread,
Oct 12, 2010, 10:58:12 PM10/12/10
to Thinking Sphinx
I've tried it with just define_index, and also with:

attr_accessible :foodcode, :maindescription, :abbrdescription

Right now it's just:

class MainFoodDesc < ActiveRecord::Base
define_index do
indexes maindescription
end
end


Pat Allan

unread,
Oct 12, 2010, 11:04:50 PM10/12/10
to thinkin...@googlegroups.com
You're going to tell the model that you're using a different primary key to 'id' - and do this before the define_index block.

--
Pat

Sebastian

unread,
Oct 13, 2010, 1:01:10 AM10/13/10
to Thinking Sphinx
Thank you! Everything is working now.

Your suggestion in another thread to make sure there's no other
searchd running also saved me.

Thanks for all your hard work and awesome support.

Cheers
Reply all
Reply to author
Forward
0 new messages