Reputation: 108
I am trying to create an index using the npm package elasticsearch and have been recieving the following error.
'No handler found for uri [/myindex] and method [POST]'
esClient.indices.create({
index: 'myindex'
}, function(err, resp, status) {
cb(err, resp);
});
The following code was working for Elasticsearch 2.3
Here is the tracelog
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]' ]
Upvotes: 0
Views: 3563
Reputation: 217274
You need to update your JavaScript client as well and instantiate it with the apiVersion
parameter set to 5.0
var esClient = new elasticsearch.Client({
host: config.es.host,
log: 'error',
apiVersion: '5.0'
});
The reason for this is that as ES 5.0 it is not possible to create a new index using the POST
HTTP method, but only with the PUT
method
Upvotes: 1