2017-02-11 37 views
0

我有名字演員一個模型,該模型看起來像下面的代碼片段的lib/searchkick/model.rb:70:在`searchkick_reindex」

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刪除索引,並試圖再次運行,但是,它給了我同樣的錯誤索引已經存在

任何人都可以請幫助找到此錯誤背後的原因

謝謝, Ravi。

回答

0

經過大量的調試,我發現了這個錯誤背後的原因。

我正在使用Searchkick v2.1.1與Elasticsearch v.5.0.1 ...這給我的運輸錯誤。

然後我用v2.4.3替換了Elasticsearch v5.0.1,然後開始正確索引。我猜在searchkick v2.1.1和Elasticsearch v5.0.1之間存在兼容性問題