In my rails application with 'elasticsearch-model' and 'elasticsearch-rails' gems installed and elasticsearch (v5.1.1) running on the default port and a model that looks like this
class Article
include Mongoid::Document
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
field :title, type: String
field :author, type: String
index_name "articles-#{Rails.env}"
end
And the initializer is something like this
Elasticsearch::Model.client = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || "http://localhost:9200/"
When I try to import or create index
Article.import force:true
Article.__elasticsearch__.create_index! force: true
I get the following error
Elasticsearch::Transport::Transport::Errors::BadRequest: [400] No handler found for uri [//articles-development] and method [DELETE]
from /Users/bgr/.rvm/gems/ruby-2.3.0/gems/elasticsearch-transport-1.0.17/lib/elasticsearch/transport/transport/base.rb:201:in `__raise_transport_error'
from /Users/bgr/.rvm/gems/ruby-2.3.0/gems/elasticsearch-transport-1.0.17/lib/elasticsearch/transport/transport/base.rb:312:in `perform_request'
from /Users/bgr/.rvm/gems/ruby-2.3.0/gems/elasticsearch-transport-1.0.17/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
from /Users/bgr/.rvm/gems/ruby-2.3.0/gems/elasticsearch-transport-1.0.17/lib/elasticsearch/transport/client.rb:128:in `perform_request'
After some investigation the issue was with my initializer. it worked after changing the host.
Elasticsearch::Model.client = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || "localhost:9200"
Update Apparently the configuration works with Elasticsearch 2.4.x.
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