Can't build indexes... 'At least one field is necessary for an index' (in Rails 3.2 w/ TS 2.0.11)

49 views
Skip to first unread message

mrpunkin

unread,
Feb 24, 2012, 5:38:35 PM2/24/12
to Thinking Sphinx
rake aborted!
At least one field is necessary for an index
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/index/builder.rb:35:in `initialize'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/index/builder.rb:22:in `new'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/index/builder.rb:22:in `generate'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/active_record.rb:203:in
`add_sphinx_index'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/active_record.rb:170:in `block in
define_index'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/active_record.rb:185:in `call'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/active_record.rb:185:in `block in
define_indexes'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/active_record.rb:184:in `each'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/active_record.rb:184:in
`define_indexes'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/configuration.rb:158:in `block in
generate'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/configuration.rb:156:in `each'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/configuration.rb:156:in `generate'
/Users/Bryan/.rvm/gems/ruby-1.9.3-p125@capture-rails3/gems/thinking-
sphinx-2.0.11/lib/thinking_sphinx/configuration.rb:172:in `build'

I have traced this down to it not actually thinking any columns are
being passed to the indexes method when trying to generate the
ThinkingSphinx::Index::Builder instance. Running Model.define_indexes
directly with a block in console results in the same error. I have
switched all my field and attribute names to symbols instead of
literals in an attempt to fix it, but still run into the same error.
I'm trying to upgrade my app from Rails 2.3.11 to Rails 3.2.1 and this
is stopping me from being able to interact with my indexed models at
the moment. Any help is much appreciated. Thanks.

mrpunkin

unread,
Feb 24, 2012, 6:21:18 PM2/24/12
to thinkin...@googlegroups.com
Also, just wanted to be sure everyone knows I don't have any index blocks that only have attributes. They all have attributes and fields, or just fields.

Pat Allan

unread,
Feb 25, 2012, 6:21:47 AM2/25/12
to thinkin...@googlegroups.com

Hi Bryan

I'm at a bit of a loss why this is happening… I've seen this in the past, but it's with pre Rails 3.1. Can you just confirm which version of builder is in your Gemfile.lock file? Also, is the blankslate gem in your Gemfile.lock file?

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/Zx0jMRwuMMQJ.
> 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.

mrpunkin

unread,
Feb 27, 2012, 11:43:22 AM2/27/12
to thinkin...@googlegroups.com
TS has builder (>= 2.1.2) but the rest of the lock file has builder (~> 3.0.0). No blankslate gem at all.

mrpunkin

unread,
Feb 28, 2012, 1:48:24 PM2/28/12
to thinkin...@googlegroups.com
Any ideas what could be causing this? This is currently stopping us from finishing our upgrade to Rails 3, due to our dependency on TS for search.

Pat Allan

unread,
Feb 29, 2012, 6:50:06 PM2/29/12
to thinkin...@googlegroups.com

Sorry, short of having access to the code and reproducing it locally, I've no idea what the cause is.

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.

> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/Pxi2ZpkjhtsJ.

Evgeniy Solovyov

unread,
Apr 30, 2012, 9:10:26 AM4/30/12
to thinkin...@googlegroups.com
In fact i have the same problem after mingration from ruby 1.8.7 to 1.9.3. May be i missed something but may be somebody can give me i hint. Rails 3.1.4, ts 2.0.11

четверг, 1 марта 2012 г., 1:50:06 UTC+2 пользователь pat написал:

> To post to this group, send email to thinking-sphinx@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphinx+unsubscribe@googlegroups.com.

Evgeniy Solovyov

unread,
Apr 30, 2012, 11:31:47 AM4/30/12
to thinkin...@googlegroups.com
Have just found that while i have define_index block but in
.../gems/thinking-sphinx-2.0.11/lib/thinking_sphinx/index/builder.rb:32 
where you may see self.instance_eval &block it returns
#<ThinkingSphinx::Index::FauxColumn:0x007ffcb6063aa0>
@name = instance_eval
stack =[]

понедельник, 30 апреля 2012 г., 16:10:26 UTC+3 пользователь Evgeniy Solovyov написал:

mrpunkin

unread,
Apr 30, 2012, 11:53:02 AM4/30/12
to thinkin...@googlegroups.com
I was able to figure out my problem actually. I had another gem / dependency that was requiring the use of BlankSlate and actually packaged it into their own Gem, but a VERY old version of it. By requiring BlankSlate in my Gemfile before this other gem I was able to get TS working as expected.

Evgeniy Solovyov

unread,
Apr 30, 2012, 1:01:32 PM4/30/12
to thinkin...@googlegroups.com
unfortunately my Gemfile.lock doesn't mention BlankSlate :(

понедельник, 30 апреля 2012 г., 18:53:02 UTC+3 пользователь mrpunkin написал:

Bryan Corey

unread,
Apr 30, 2012, 1:02:55 PM4/30/12
to thinkin...@googlegroups.com
Mine didn't either, it was actually packaged in as a class of another Gem I was using, not a dependency for that gem. I'd try manually installing BlankSlate higher up your Gemfile just to see if it can help. If not, I won't be much help, sorry.


To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/53mXSnYZkm8J.
To post to this group, send email to thinkin...@googlegroups.com.
To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.

Evgeniy Solovyov

unread,
Apr 30, 2012, 3:55:35 PM4/30/12
to thinkin...@googlegroups.com
Thank you!

Realy strange solution but works.
To sum up, to solve this issue just place:
gem 'blankslate'
somewhere at the top of your Gemfile 

понедельник, 30 апреля 2012 г., 20:02:55 UTC+3 пользователь mrpunkin написал:

Pat Allan

unread,
May 1, 2012, 8:49:14 AM5/1/12
to thinkin...@googlegroups.com
Fantastic investigation, thanks for the fix Bryan, just updated the docs:
http://freelancing-god.github.com/ts/en/common_issues.html#no-fields

--
Pat

>> > 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.
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
>> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/53mXSnYZkm8J.

>> 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.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.

> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/pWkiZjJbYZkJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages