[英]Elasticsearch::Transport::Transport::Errors::BadRequest error heroku
[英]Elasticsearch::Transport::Transport::Errors::BadRequest [400] while creating index
在我安装了“elasticsearch-model”和“elasticsearch-rails”gems 的 rails 应用程序中,并在默认端口上运行 elasticsearch (v5.1.1) 和一个看起来像这样的模型
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
初始化程序是这样的
Elasticsearch::Model.client = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || "http://localhost:9200/"
当我尝试导入或创建索引时
Article.import force:true
Article.__elasticsearch__.create_index! force: true
我收到以下错误
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'
经过一番调查,问题出在我的初始化程序上。 更换主机后就可以使用了。
Elasticsearch::Model.client = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || "localhost:9200"
更新显然该配置适用于 Elasticsearch 2.4.x。
在我的场景中,更改 DATABASE_URL 格式,在.env
或任何你保存它的地方,从:
DATABASE_URL=postgres:/myapp_development?pool=5
到:
DATABASE_URL=postgresql://user:password@localhost:5432/myapp_development
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.