Sphinx守护程序返回错误:index product_core:INTERNAL ERROR:传入模式不匹配。仅在登台服务器上

时间:2012-03-12 10:33:30

标签: ruby-on-rails sphinx thinking-sphinx

该应用程序使用的是Rails 2.3.12和ThinkingSphinx 1.4.11。产品型号只有一个索引,它在开发盒上运行正常。在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 console之后我得到了:

>> 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登台配置(共享部分,链接等)中解决,但是现在我想让它在手动后工作我将自动化。

1 个答案:

答案 0 :(得分:3)

我得到了同样的错误,这是因为我为同一个字段创建了2个索引,一个作为索引,另一个作为属性。

由于Thinking Sphinx语法与常规sphinx.conf语法完全不同,因此可能非常混乱。对于常规的sphinx.conf,您必须创建普通字段,然后还必须创建与CRC32整数相同的字段,以便将它们用于加权。

在Thinking Sphinx中你不需要这样做。

在上面的account_id的情况下,我猜你已经创建了两次,因此错误,你只需要在模型的define_index块中创建一次:

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 ,但我离开了它,因为您可以将非整数字段转换为一个用于称重的字段,例如:

{{1}}