【问题标题】:'No handler found for uri [/myindex] and method [POST]' Elasticsearch 5.0.3 with nodejs esclient'没有为 uri [/myindex] 和方法 [POST] 找到处理程序' Elasticsearch 5.0.3 与 nodejs esclient
【发布时间】:2017-08-28 09:55:40
【问题描述】:

我正在尝试使用 npm 包 elasticsearch 创建索引并收到以下错误。

'未找到 uri [/myindex] 和方法 [POST] 的处理程序'

esClient.indices.create({ index: 'myindex' }, function(err, resp, status) { cb(err, resp); });

以下代码适用于 Elasticsearch 2.3

这是跟踪日志

Elasticsearch DEBUG: 2017-04-03T13:54:24Z
  starting request { method: 'POST', path: '/myindex1', query: {} }


Elasticsearch TRACE: 2017-04-03T13:54:24Z
  -> POST http://localhost:9200/myindex1

  <- 400
  No handler found for uri [/myindex1] and method [POST]

Elasticsearch DEBUG: 2017-04-03T13:54:24Z
  Request complete

{ Error: Bad Request
    at respond (/Users/Ut/Fitternity/metropolis/node_modules/elasticsearch/src/lib/transport.js:293:15)
    at checkRespForFailure (/Users/Ut/Fitternity/metropolis/node_modules/elasticsearch/src/lib/transport.js:252:7)
    at HttpConnector.<anonymous> (/Users/Ut/Fitternity/metropolis/node_modules/elasticsearch/src/lib/connectors/http.js:155:
7)
    at IncomingMessage.wrapper (/Users/Ut/Fitternity/metropolis/node_modules/elasticsearch/node_modules/lodash/index.js:3095
:19)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:926:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
  status: 400,
  displayName: 'BadRequest',
  message: 'Bad Request' } 'No handler found for uri [/myindex1] and method [POST]' 400
[ 'No handler found for uri [/myindex1] and method [POST]' ]

【问题讨论】:

  • 您能否也展示一下您是如何创建esClient 的?
  • var esClient = new elasticsearch.Client({ host: config.es.host, log: 'error' });
  • 您是否也更新了 JavaScript 客户端?

标签: javascript node.js elasticsearch


【解决方案1】:

您还需要更新您的 JavaScript 客户端并使用 apiVersion parameter set to 5.0 实例化它

var esClient = new elasticsearch.Client({ 
   host: config.es.host, 
   log: 'error',
   apiVersion: '5.0'
});

原因是在 ES 5.0 中无法使用POST HTTP 方法创建新索引,只能使用PUT 方法

【讨论】:

  • 嘿@Val 我遇到了同样的问题,你能告诉我如何解决它吗?
  • @awsmsid 随时创建一个新问题来解释您的确切问题。
  • 当然让我创建一个新问题。
  • 嘿@Val 请检查我的问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-28
  • 1970-01-01
  • 2022-01-16
  • 1970-01-01
  • 2016-12-13
  • 1970-01-01
相关资源
最近更新 更多