1. Go to this page and download the library: Download flyokai/amp-opensearch 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/ */
flyokai / amp-opensearch example snippets
use Flyokai\AmpOpensearch\AmpHandler;
use Flyokai\AmpOpensearch\HttpClientBuilder;
use OpenSearch\ClientBuilder;
$handler = new AmpHandler(
(new HttpClientBuilder())->build(),
retryLimit: 3,
retryDelay: 0.1,
);
$client = (new ClientBuilder())
->setHandler($handler)
->setHosts(['https://localhost:9200'])
->setBasicAuthentication('admin', 'admin')
->setSSLVerification(false)
->build();
$client->index([
'index' => 'products',
'id' => 1,
'body' => ['name' => 'Foo', 'price' => 9.99],
]);
$result = $client->search([
'index' => 'products',
'body' => ['query' => ['match' => ['name' => 'Foo']]],
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.