我有一个名为 Actor 的模型,模型看起来像以下代码段
class Actor
include Mongoid::Document
field :name, type: String
field :birthName, as: :birth_name, type: String
field :date_of_birth, type: Date
field :height, type: Measurement
field :bio, type: String
searchkick
end
当我尝试使用Actor.reindex
重新索引我的模型时,我收到以下错误,显示索引已存在的根本原因。
irb(main):001:0> Actor.reindex
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"index_already_exists_exception","reason":"index [actors_development_20170209175219593/TKOPkMY1TsGNEYmWlVCKo
A] already exists","index_uuid":"TKOPkMY1TsGNEYmWlVCKoA","index":"actors_development_20170209175219593"}],"type":"index_already_exists_exception","reason":"index [actors_development_20170209175219593/TKO
PkMY1TsGNEYmWlVCKoA] already exists","index_uuid":"TKOPkMY1TsGNEYmWlVCKoA","index":"actors_development_20170209175219593"},"status":400}
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/elasticsearch-transport-5.0.1/lib/elasticsearch/transport/transport/base.rb:201:in `__raise_transport_error'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/elasticsearch-transport-5.0.1/lib/elasticsearch/transport/transport/base.rb:318:in `perform_request'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/elasticsearch-transport-5.0.1/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/elasticsearch-transport-5.0.1/lib/elasticsearch/transport/client.rb:128:in `perform_request'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/elasticsearch-api-5.0.1/lib/elasticsearch/api/namespace/common.rb:21:in `perform_request'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/elasticsearch-api-5.0.1/lib/elasticsearch/api/actions/indices/create.rb:86:in `create'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/searchkick-2.1.1/lib/searchkick/index.rb:14:in `create'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/searchkick-2.1.1/lib/searchkick/index.rb:177:in `create_index'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/searchkick-2.1.1/lib/searchkick/index.rb:226:in `reindex_scope'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/searchkick-2.1.1/lib/searchkick/model.rb:70:in `searchkick_reindex'
from (irb):1
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/ravi/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'from bin/rails:4:in `require'
由于错误显示索引已存在,然后我从elasticsearch删除了索引并尝试再次运行但是,它给了我同样的错误索引已经存在
任何人都可以帮助找到导致此错误的原因
谢谢, 拉维。
答案 0 :(得分:0)
经过大量调试后,我发现了该错误背后的原因。
我正在使用带有Elasticsearch v.5.0.1的Searchkick v2.1.1 ...这给了我传输错误。
然后我用v2.4.3替换了Elasticsearch v5.0.1。然后它开始正确索引。我想searchkick v2.1.1和Elasticsearch v5.0.1之间存在兼容性问题