現在、WebappでElasticSearchを実装中です。公式elasticsearch-php frameworkを使用してこれを行います。私たちはこれを新しいモデルにしたので、これをモデルに直接実装してテストしました。ElasticSearchが更新されていません
public function afterSave()
{
$client = \Elasticsearch\ClientBuilder::create()->build();
$params = [
'index' => 'testindex',
'type' => 'user',
'id' => $this->id,
'body' => [
'id' => $this->id,
'name' => $this->firstname.' '.$this->lastname,
'email' => $this->email,
'test' => ''
]
];
$response = $client->index($params);
}
public function afterUpdate()
{
$client = \Elasticsearch\ClientBuilder::create()->build();
$params = [
'index' => 'testindex',
'type' => 'user',
'id' => $this->id
];
$params['body']['doc'] = [
'test' => 'test2'
];
$response = $client->update($params);
var_dump($client->update($params));
var_dump($response);
}
モデルを保存すると自動的にモデルに追加されますが、モデルを更新してもモデルは更新されません。私がvar_dump()
の応答を返すと、エラーは発生しません。
array(4) { ["index"]=> string(11) "testindex" ["type"]=> string(5) "user" ["id"]=> string(5) "20604" ["body"]=> array(1) { ["doc"]=> array(1) { ["test"]=> string(5) "test2" } } }
array(4) { ["_index"]=> string(11) "testindex" ["_type"]=> string(5) "user" ["_id"]=> string(5) "20604" ["_version"]=> int(2) }
array(4) { ["_index"]=> string(11) "testindex" ["_type"]=> string(5) "user" ["_id"]=> string(5) "20604" ["_version"]=> int(3) }
私はここで間違っていますか?
、更新が働いていたことを意味する、と思われます。 'curl -XGET localhost:9200/testindex/user/20604'を実行するとどうなりますか? – Val
同じ、間違った出力。 "_index": "testindex"、 "_ type": "user"、 "_ id": "20604"、 "_ version":4、 "found":true、 "_ source":{"id": "20604" "name": "test person"、 "email": "[email protected]"、 "test": ""}} ' –
あなたがシェルから与えたカールを実行すると、 id '20604'で、それを共有してください。 – Val