简体   繁体   English

Elasticsearch::Transport::Transport::Errors::BadRequest [400] 创建索引时

[英]Elasticsearch::Transport::Transport::Errors::BadRequest [400] while creating index

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在我安装了“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

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.更新显然该配置适用于 Elasticsearch 2.4.x。

In my scenario, changing DATABASE_URL format, in .env or wherever You keep it, from:在我的场景中,更改 DATABASE_URL 格式,在.env或任何你保存它的地方,从:

DATABASE_URL=postgres:/myapp_development?pool=5

to:到:

DATABASE_URL=postgresql://user:password@localhost:5432/myapp_development

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elasticsearch ::运输::运输::错误:: BadRequest错误heroku - Elasticsearch::Transport::Transport::Errors::BadRequest error heroku 搜索#search中的Rails:Elasticsearch :: Transport :: Transport :: Errors :: BadRequest - Rails: Elasticsearch::Transport::Transport::Errors::BadRequest in Search#search Elasticsearch :: Transport :: Transport :: Errors :: NotFound:[404] - Elasticsearch::Transport::Transport::Errors::NotFound: [404] Elasticsearch :: Transport :: Transport :: Errors :: NotFound([404] {“错误”:{“ root_cause”:[{“类型”:“ index_not_found_exception” - Elasticsearch::Transport::Transport::Errors::NotFound ([404] {“error”:{“root_cause”:[{“type”:“index_not_found_exception” 使用ActiveAdmin,SearchKick和SearchBox在Heroku上出现Elasticsearch :: Transport :: Transport :: Errors - Elasticsearch::Transport::Transport::Errors on Heroku with ActiveAdmin, SearchKick and SearchBox Activeadmin破坏记录,并在管理中出现Elasticsearch :: Transport :: Transport :: Errors :: NotFound异常[404] - Activeadmin Destroy Record with Exception Elasticsearch::Transport::Transport::Errors::NotFound in Admin [404] Elasticsearch::Transport::Transport::Errors::Forbidden: [403] 发送超过 1200 个字符的文本字段时出错 - Elasticsearch::Transport::Transport::Errors::Forbidden: [403] error when sending text fields with more than 1200 characters Elasticsearch :: Transport :: Transport :: Errors :: NotAcceptable:[406] {“错误”:“不支持Content-Type标头[]”,“状态”:406} - Elasticsearch::Transport::Transport::Errors::NotAcceptable: [406] {“error”:“Content-Type header [] is not supported”,“status”:406} 创建索引的Elasticsearch问题(Rails) - Elasticsearch issue with creating index (Rails) 如何禁用 HTTP 严格传输安全? - How to disable HTTP Strict Transport Security?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM