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

On 13/10/2010, at 1:58 PM, Sebastian wrote:

> 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
> 
> 
> On Oct 12, 10:26 pm, Pat Allan <[email protected]> wrote:
>> Hmm, right. What does your MainFoodDesc model code look like?
>> 
>> --
>> Pat
>> 
>> On 13/10/2010, at 12:33 PM, Sebastian wrote:
>> 
>> 
>> 
>>> 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?
>> 
>>> On Oct 12, 9:09 pm, Pat Allan <[email protected]> wrote:
>>>> Ah, right. Are you using non-integer primary keys?
>> 
>>>> --
>>>> Pat
>> 
>>>> On 13/10/2010, at 12:06 PM, Sebastian wrote:
>> 
>>>>> 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 <[email protected]> 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
>> 
>>>>>> On 13/10/2010, at 9:15 AM, Sebastian <[email protected]> wrote:
>> 
>>>>>>> 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?
>> 
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "Thinking Sphinx" group.
>>>>>>> To post to this group, send email to [email protected].
>>>>>>> To unsubscribe from this group, send email to 
>>>>>>> [email protected].
>>>>>>> For more options, visit this group 
>>>>>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
>> 
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "Thinking Sphinx" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to 
>>>>> [email protected].
>>>>> For more options, visit this group 
>>>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Thinking Sphinx" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to 
>>> [email protected].
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 

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

Reply via email to