# clientbuilder example php (ok)

Ví dụ 1:

C:\Users\Administrator\AppData\Local\Temp\scp55598\home\admin\domains\yp.vn\public\_html\apiyp.php

```
use Elasticsearch\ClientBuilder;
require 'vendor/autoload.php';
$client = ClientBuilder::create()->build();
$params = [
  'index' => 'my_index',
  'id'    => 'my_id',
  'body'  => ['testField' => 'abc']
];
$response = $client->index($params);
print_r($response);
```

![](https://3988971916-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LXUV09EJOZ8BKB8YL5I%2F-MPmh4fspZTFN32XZMLH%2F-MPmxdroTsez1SwZ0TzU%2FScreenshot_2.jpg?alt=media\&token=79a0253a-4aab-4eb0-befe-55bc85b2dad7)

Ví dụ 2:

```
<?php  
	// https://yp.vn/apiyp.php?findtext=findtext&longtituide=longtituide&lengtituide=lengtituide&distance=distance
	use Elasticsearch\ClientBuilder;
	require 'vendor/autoload.php';
	$client = ClientBuilder::create()->build();
	// $params = [
	//   'index' => 'my_index',
	//   'id'    => 'my_id',
	//   'body'  => ['testField' => 'abc']
	// ];
	// $response = $client->index($params);
	$params = [
    'index' => 'my_index',
    'id' => 'my_id'
	];

	$response = $client->get($params);
	print_r($response);
?>
```
