在我的rails应用程序中,安装了' elasticsearch - model‘和'elasticsearch-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'发布于 2017-01-09 18:07:22
经过一番调查,问题出在我的初始化器上。它在更换主机后起了作用。
Elasticsearch::Model.client = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || "localhost:9200"显然,更新的配置适用于ElasticSearch2.4.x。
发布于 2020-04-16 12:25:16
在我的场景中,更改DATABASE_URL格式、使用.env或保存它的地方:
DATABASE_URL=postgres:/myapp_development?pool=5至:
DATABASE_URL=postgresql://user:password@localhost:5432/myapp_developmenthttps://stackoverflow.com/questions/41514864
复制相似问题