Creating an index with Elasticsearch 5.0 throws a

2019-06-07 09:35发布

问题:

I use Elasticsearch 2.4 and I decided to test my code with Elasticsearch 5.0.

So, I installed Elasticsearch 5.0, started it and then tried to use my PHP function that creates an index and populates it.

But I get this error :

 Elasticsearch\Common\Exceptions\BadRequest400Exception
 No handler found for uri [/devmaestro_fr_articles] and method [POST]

And this one :

 Guzzle\Http\Exception\ClientErrorResponseException
 Client error response
[status code] 400
[reason phrase] Bad Request
[url] http://localhost:9200/devmaestro_fr_articles

If I use the same PHP function with Elasticsearch 2.4, it works fine. So, do you have any idea about this problem? Is the way to create an index into Elasticsearch 5.0 different than Elasticsearch 2.4?

I'm developing a web app based on Zend Framework.

回答1:

It used to be possible to create an index using either POST or PUT, but since the Pull Request #20001, it is not possible anymore to use POST and only PUT is allowed.

So you simply need to change POST with PUT in your code and it should work.