关于索引的 Thinking Sphinx 3.1.4 ActiveRecord::ConfigurationError
Thinking Sphinx 3.1.4 ActiveRecord::ConfigurationError on indexing
我正在 Rails 3.2.21 和 Thinking-Sphinx 3.1.4 使用 Sphinx 2.2.9-id64-release (rel22-r5006)。
我刚从 mysql 转移到 postgres,当我索引时我得到这个错误:
production@vagrant:/opt/rails/production/current$ rake ts:index --trace
** Invoke ts:index (first_time)
** Invoke environment (first_time)
** Execute environment
** [Raven] Raven 0.13.3 ready to catch errors
** Execute ts:index
Generating configuration to /opt/data/production-schedule/sphinx/development.sphinx.conf
rake aborted!
ActiveRecord::ConfigurationError: #<Proc:0x007f8daccfec20@/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/filter_reflection.rb:57 (lambda)>
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:131:in `build'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:24:in `block in graft'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:22:in `each'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:22:in `graft'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:364:in `build_joins'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:266:in `build_arel'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:260:in `arel'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation.rb:459:in `to_sql'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_builder.rb:11:in `sql_query'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_source.rb:119:in `build_sql_query'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_source.rb:135:in `prepare_for_render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_source.rb:65:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration/index.rb:29:in `block in render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration/index.rb:29:in `collect'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration/index.rb:29:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/core/index.rb:57:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration.rb:43:in `block in render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration.rb:43:in `collect'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration.rb:43:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/configuration.rb:93:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/configuration.rb:99:in `block in render_to_file'
/home/production/.rbenv/versions/2.1.2/lib/ruby/2.1.0/open-uri.rb:36:in `open'
/home/production/.rbenv/versions/2.1.2/lib/ruby/2.1.0/open-uri.rb:36:in `open'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/configuration.rb:99:in `render_to_file'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/rake_interface.rb:24:in `configure'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/rake_interface.rb:35:in `index'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/tasks.rb:9:in `block (2 levels) in <top (required)>'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/production/.rbenv/versions/2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/home/production/.rbenv/versions/2.1.2/bin/rake:23:in `load'
/home/production/.rbenv/versions/2.1.2/bin/rake:23:in `<main>'
Tasks: TOP => ts:index
我将索引缩小到仅有的两个可能导致错误的条目,它似乎与多态关系有关:
ThinkingSphinx::Index.define(:project, name: 'project', with: :active_record, delta: true) do
indexes data.itemcode, as: :itemcode
polymorphs data, to: PROJECT_DATA_TYPES.map(&:camelize)
end
知道为什么这不起作用吗?
通过堆栈跟踪,您正在使用 Rails 3.2 和 Thinking Sphinx 3.1.4 - Rails 3.2 的多态关联支持在 TS v3.1.4 中被删除(如 'Upgrading' the release notes 的部分)。 ActiveRecord 内部代码定期更改,并且支持 3.2 和 4.x 的特定功能实在是太痛苦了。
如果您刚刚升级了 TS 并且有一个可以使用的早期版本,您可能想切换回那个版本。或者升级到 Rails 4.0? :)
我正在 Rails 3.2.21 和 Thinking-Sphinx 3.1.4 使用 Sphinx 2.2.9-id64-release (rel22-r5006)。
我刚从 mysql 转移到 postgres,当我索引时我得到这个错误:
production@vagrant:/opt/rails/production/current$ rake ts:index --trace
** Invoke ts:index (first_time)
** Invoke environment (first_time)
** Execute environment
** [Raven] Raven 0.13.3 ready to catch errors
** Execute ts:index
Generating configuration to /opt/data/production-schedule/sphinx/development.sphinx.conf
rake aborted!
ActiveRecord::ConfigurationError: #<Proc:0x007f8daccfec20@/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/filter_reflection.rb:57 (lambda)>
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:131:in `build'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:24:in `block in graft'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:22:in `each'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:22:in `graft'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:364:in `build_joins'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:266:in `build_arel'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:260:in `arel'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation.rb:459:in `to_sql'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_builder.rb:11:in `sql_query'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_source.rb:119:in `build_sql_query'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_source.rb:135:in `prepare_for_render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_source.rb:65:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration/index.rb:29:in `block in render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration/index.rb:29:in `collect'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration/index.rb:29:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/core/index.rb:57:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration.rb:43:in `block in render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration.rb:43:in `collect'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration.rb:43:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/configuration.rb:93:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/configuration.rb:99:in `block in render_to_file'
/home/production/.rbenv/versions/2.1.2/lib/ruby/2.1.0/open-uri.rb:36:in `open'
/home/production/.rbenv/versions/2.1.2/lib/ruby/2.1.0/open-uri.rb:36:in `open'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/configuration.rb:99:in `render_to_file'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/rake_interface.rb:24:in `configure'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/rake_interface.rb:35:in `index'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/tasks.rb:9:in `block (2 levels) in <top (required)>'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/production/.rbenv/versions/2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/home/production/.rbenv/versions/2.1.2/bin/rake:23:in `load'
/home/production/.rbenv/versions/2.1.2/bin/rake:23:in `<main>'
Tasks: TOP => ts:index
我将索引缩小到仅有的两个可能导致错误的条目,它似乎与多态关系有关:
ThinkingSphinx::Index.define(:project, name: 'project', with: :active_record, delta: true) do
indexes data.itemcode, as: :itemcode
polymorphs data, to: PROJECT_DATA_TYPES.map(&:camelize)
end
知道为什么这不起作用吗?
通过堆栈跟踪,您正在使用 Rails 3.2 和 Thinking Sphinx 3.1.4 - Rails 3.2 的多态关联支持在 TS v3.1.4 中被删除(如 'Upgrading' the release notes 的部分)。 ActiveRecord 内部代码定期更改,并且支持 3.2 和 4.x 的特定功能实在是太痛苦了。
如果您刚刚升级了 TS 并且有一个可以使用的早期版本,您可能想切换回那个版本。或者升级到 Rails 4.0? :)