2016-11-15 11 views
1

私はelasticsearch 5.0.0とelasticsearch-phpを新しくインストールしました。私はインデックスを作成しようとしています。elasticsearch-php create indexは BadRequest400Exceptionを返します

私はthisインデックス管理ドキュメントからのコード実行:

$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]' 

任意のアイデアなぜですか?

私はelasticsearch 2.0

EDITを使用したときに動作するために使用されるこのコードは:それはelasticsearch-PHPの問題ですか、私は私がelasticquentを使用しています

を推測、それを更新する必要がありますいずれかのように、私はthis質問を見つけましたこれは私がちょうど実現したelasticsearch-PHPのバージョンが必要です< 2.2ので、これはエラーメッセージを見ると、問題

+0

入れ替えることができますか? '{" error ":{" error_cause ":{{" type ":}}を返す' $ response = $ client-> indices() - > putSettings($ params); ' –

+0

これは' Elasticsearch \ Common \ Exceptions \ Missing404Exceptionを返す ' 「index_not_found_exception」、「reason」:「no such index」、「resource.type」:「index_or_alias」、「resource.id」:「my_index」、「index_uuid」:「_ na _」、「index」:「my_index」} ]、 "type": "index_not_found_exception"、 "reason": "no such index"、 "resource.type": "index_or_alias"、 "resource.id": "my_index"、 "index_uuid": "_ na _"、 "index ":" my_index "}、" status ":404} ' ' – user3494047

答えて

1

引き起こしているものです。

No handler found for uri [/my_index] and method [POST] 

これは、create index callがHTTP POSTメソッドを使用していることを意味します。以前のバージョン(5.0より前)では、elasticsearch-phpクライアントがHTTP POSTを使用してインデックスを作成しましたが、ES 5.0ではHTTP PUTのみが新しいインデックスを作成するために使用されていました。

This change septemberに戻ると、これはES 5.0との互換性のある呼び出しを再度作成しました。

唯一の説明は、ES 5.0がインストールされているが、5.0バージョンのelasticsearch-phpクライアントがインストールされていないことです。あなたがElasticquent doesn't yet support ES 5を実行しているので

、あなたは一時的に、常に再び動作しますPUT代わりのPOSTとお電話を返すようにEndpoints/Indices/Create.getMethod()方法を変更することでこの問題に行くことができますが、他の非互換性に遭遇するかもしれません。

関連する問題