PHP code example of wa72 / es-tools
1. Go to this page and download the library: Download wa72/es-tools library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wa72 / es-tools example snippets
use OpenSearch\GuzzleClientFactory;
use Wa72\ESTools\Index;
$client = (new GuzzleClientFactory())->create([
'base_uri' => 'http://localhost:9200',
]);
$index = new Index($client, 'articles', [
'properties' => ['title' => ['type' => 'text']],
], [], []);
$index->prepare();
$index->index(['title' => 'First article'], '1');
$document = $index->get('1');
bash
composer