该应用程序使用 Rails 2.3.12 和 ThinkingSphinx 1.4.11。 Product model 上只有一个索引,它在 devel box 上工作正常。在 cap staging deploy
之后,我在服务器上生成配置、创建索引并启动守护进程:
bundle exec rake ts:conf RAILS_ENV=staging
bundle exec rake ts:index RAILS_ENV=staging
bundle exec rake ts:start RAILS_ENV=staging
进入 Rails 控制台后,我得到:
>> Product.search('music')
Sphinx Sphinx Daemon returned error: index product_core: INTERNAL ERROR: incoming- schema mismatch (in=uint account_id:32@192, my=uint account_id:32@0)
ThinkingSphinx::SphinxError: index product_core: INTERNAL ERROR: incoming-schema mismatch (in=uint account_id:32@192, my=uint account_id:32@0)
from /var/www/rebelshop_staging/rebelshop/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.4.11/lib/thinking_sphinx/search.rb:417:in `populate'
from /var/www/rebelshop_staging/rebelshop/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.4.11/lib/thinking_sphinx/search.rb:562:in `call'
from /var/www/rebelshop_staging/rebelshop/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.4.11/lib/thinking_sphinx/search.rb:562:in `retry_on_stale_index'
from /var/www/rebelshop_staging/rebelshop/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.4.11/lib/thinking_sphinx/search.rb:404:in `populate'
from /var/www/rebelshop_staging/rebelshop/shared/bundle/ruby/1.8/gems/thinking-sphinx-1.4.11/lib/thinking_sphinx/search.rb:167:in `method_missing'
from /usr/local/lib/ruby/1.8/irb.rb:310:in `output_value'
from /usr/local/lib/ruby/1.8/irb.rb:159:in `eval_input'
from /usr/local/lib/ruby/1.8/irb.rb:271:in `signal_status'
from /usr/local/lib/ruby/1.8/irb.rb:155:in `eval_input'
from /usr/local/lib/ruby/1.8/irb.rb:154:in `eval_input'
from /usr/local/lib/ruby/1.8/irb.rb:71:in `start'
from /usr/local/lib/ruby/1.8/irb.rb:70:in `catch'
from /usr/local/lib/ruby/1.8/irb.rb:70:in `start'
from /usr/local/bin/irb:13
当然我知道在每次 cap staging deploy
之后生成这样的索引是次优的,它应该在 capistrano staging 配置(共享部分、链接等)中解决,但现在我想得到它手动工作,之后我将自动化。
最佳答案
我遇到了同样的错误,这是因为我为同一个字段创建了 2 个索引,一个作为索引,另一个作为属性。
由于 Thinking Sphinx 语法与常规 sphinx.conf 语法完全不同,因此可能会非常困惑。对于常规 sphinx.conf,您必须创建普通字段,然后还必须创建与 CRC32 整数相同的字段,以便将它们用于加权。
在 Thinking Sphinx 中,您不需要这样做。
在上面的 account_id 的情况下,我猜你已经创建了两次,因此错误,你只需要在模型的 define_index
block 中创建它一次:
has account_id
或者如果您需要 account_id 字段用于其他用途,请为 Sphinx 属性创建另一个别名:
indexes account_id
has account_id, :type => :integer, :as => :account_id_attribute
如果 :type => :integer
已经是一个整数,则它不是必需的,但我保留它是因为您可以将一个非整数字段转换为一个用于称重的字段,例如:
has "CRC32(media)", :type => :integer, :as => :media
关于ruby-on-rails - Sphinx 守护进程返回错误 : index product_core: INTERNAL ERROR: incoming-schema mismatch. 仅在登台服务器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9665449/