Creating an index with Elasticsearch 5.0 throws a Bad Request exception

て烟熏妆下的殇ゞ 提交于 2020-01-14 04:45:06

问题


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.



来源:https://stackoverflow.com/questions/40524056/creating-an-index-with-elasticsearch-5-0-throws-a-bad-request-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!