I'm running search kick and elastic search and i keep trying to recreate my index because my rails app is crashing but this keeps failing too. I am very new to this so feeling quite lost.
I run rake environment elasticsearch:import:all FORCE=y
But the error is
Starting up a new ElasticSearch client with 
[IMPORT] Loading models from: /home/ubuntu/workspace/sample_app/app/models
2016-03-11 16:32:07 +0000: [Faraday::ConnectionFailed] Connection refused - connect(2) for "localhost" port 9200 {:host=>"localhost", :port=>9200, :protocol=>"http"}
rake aborted!
ArgumentError: users does not exist to be imported into. Use create_index! or the :force option to create it.
/usr/local/rvm/gems/ruby-2.2.1/gems/elasticsearch-model-0.1.8/lib/elasticsearch/model/importing.rb:118:in `import'
/usr/local/rvm/gems/ruby-2.2.1/gems/elasticsearch-model-0.1.8/lib/elasticsearch/model.rb:115:in `import'
/home/ubuntu/workspace/sample_app/app/models/user.rb:109:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:457:in `load'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:457:in `block in load_file'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:647:in `new_constants_in'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:456:in `load_file'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:354:in `require_or_load'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:494:in `load_missing_constant'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:184:in `const_missing'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:261:in `const_get'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:261:in `block in constantize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:259:in `each'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:259:in `inject'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/inflector/methods.rb:259:in `constantize'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
/usr/local/rvm/gems/ruby-2.2.1/gems/elasticsearch-rails-0.1.8/lib/elasticsearch/rails/tasks/import.rb:93:in `block (4 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/elasticsearch-rails-0.1.8/lib/elasticsearch/rails/tasks/import.rb:87:in `each'
/usr/local/rvm/gems/ruby-2.2.1/gems/elasticsearch-rails-0.1.8/lib/elasticsearch/rails/tasks/import.rb:87:in `block (3 levels) in <top (required)>'
Tasks: TOP => elasticsearch:import:all
(See full trace by running task with --trace)
                We were having the same issue this morning.
The elastic-search-model documentation tells you to set up your models like this:
class User < ActiveRecord::Base
  include Elasticsearch::Model
  include Elasticsearch::Model::Callbacks
  #The rest of your mode...
end
User.import
But before importing your existing data, you need to remove User.import then run rake environment elasticsearch:import:all FORCE=y and everything will go smoothly.
Remember to add User.import after running the rake task so your new users will be imported properly.
Happy Coding!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With