使用 Elasticsearch 5.0 创建索引抛出 Bad Request 异常

Creating an index with Elasticsearch 5.0 throws a Bad Request exception

我使用 Elasticsearch 2.4,我决定用 Elasticsearch 5.0 测试我的代码。

所以,我安装了 Elasticsearch 5.0,启动了它,然后尝试使用我的 PHP 函数来创建索引并填充它。

但是我得到这个错误:

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

还有这个:

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

如果我在 Elasticsearch 2.4 中使用相同的 PHP 函数,它工作正常。 那么,你对这个问题有什么想法吗?在 Elasticsearch 5.0 中创建索引的方式与 Elasticsearch 2.4 不同吗?

我正在开发基于 Zend Framework 的 Web 应用程序。

以前可以使用 POST 或 PUT 创建索引,但自从 the Pull Request #20001 以来,不再可能使用 POST,只能使用 PUT。

因此,您只需在代码中使用 PUT 更改 POST 即可。