我有一个新的安装ElasticSearch5.0.0和elasticsearch。我正在尝试创建一个索引。
我从这索引管理文档中运行代码:
$client = ClientBuilder::create()->build();
$params = [
'index' => 'my_index'
];
// Create the index
$response = $client->indices()->create($params);而且起作用了。我成功地创建了一个索引。
我尝试下一个代码片段:
$client = ClientBuilder::create()->build();
$params = [
'index' => 'my_index',
'body' => [
'settings' => [
'number_of_shards' => 3,
'number_of_replicas' => 2
],
'mappings' => [
'my_type' => [
'_source' => [
'enabled' => true
],
'properties' => [
'first_name' => [
'type' => 'string',
'analyzer' => 'standard'
],
'age' => [
'type' => 'integer'
]
]
]
]
]
];
// Create the index with mappings and settings now
$response = $client->indices()->create($params);我得到了:
Elasticsearch\Common\Exceptions\BadRequest400Exception with message 'No handler found for uri [/my_index] and method [POST]'知道为什么吗?
当我使用ElasticSearch2.0时,这段代码曾经起作用
编辑:我发现了这问题,所以要么是elasticsearch的问题,要么我需要更新它。
我正在使用弹性what,我刚刚意识到需要elasticsearch-php版本<2.2,所以这就是造成问题的原因。
发布于 2016-11-16 04:37:01
查看错误消息:
No handler found for uri [/my_index] and method [POST]这意味着您的create调用使用的是一个HTTP方法。在以前的版本(即pre5.0)中,elasticsearch-php客户端使用HTTP创建索引,但是由于ES5.0只接受HTTP来创建新的索引。
早在9月份,这一变化就让这个create调用再次与ES 5.0兼容。
唯一可能的解释是您安装了ES 5.0,但没有安装elasticsearch-php客户端的5.0版本。
因为您正在运行Elasticquent哪个还不支持ES 5,您可以通过修改Endpoints/Indices/Create.getMethod()方法来暂时解决这个问题,使其始终返回PUT而不是POST,您的调用将再次工作,但您可能会遇到其他不兼容的情况。
https://stackoverflow.com/questions/40619182
复制相似问题