$_config = array('host' =>'192.168.1.60', // host'port' => 39200,);$client = new Elastica\Client($_config);try {$document = new Elastica\Document();$id = '23';$time = time();$data =array('name'=>'9999','age'=> '9999','test'=>'just for test ','time'=>$time);$typestr = "bfire";$indexstr = "abc";//$document->setId($id);$document->setData($data);$document->setType($typestr);$document->setIndex($indexstr);//更新/*** Update document, using update script. Requires elasticsearch >= 0.19.0** @param int $id document id* @param array|\Elastica\Script|\Elastica\Document $data raw data for request body* @param string $index index to update* @param string $type type of index to update* @param array $options array of query params to use for query. For possible options check es api* @return \Elastica\Response* @link http://www.elasticsearch.org/guide/reference/api/update.html*/$reindex = $client->updateDocument($id, $document, $indexstr, $typestr);echo 'in try ';} catch (Exception $e) {echo 'in error';var_dump($e);}echo 'all the end';
