webgriffe/amp-elasticsearch
is a non-blocking ElasticSearch client for use with the amp
concurrency framework.
⬆️ Updated fork requiring PHP 8.1+, AMPHP 5+ and tested with Elasticsearch 8.12+.
\Webgriffe\AmpElasticsearch\Client::existsIndex()
returnsfalse
instead of forwarding the 404 Error returned by the underlying HTTP client when the index does not exist.\Webgriffe\AmpElasticsearch\Client::existsDocument()
same as above for documents.
⭐ Original project (for PHP<8): https://github.com/webgriffe/amp-elasticsearch ⭐
Required PHP Version
- PHP 8.1+
Installation
composer config repositories.nanawel-amp-elasticsearch vcs https://github.com/nanawel/amp-elasticsearch.git
composer require webgriffe/amp-elasticsearch:dev-master
Usage
Just create a client instance and call its public methods which returns promises:
Loop::run(function () {
$client = new Webgriffe\AmpElasticsearch\Client('http://my.elasticsearch.test:9200');
yield $this->client->createIndex('myindex');
$response = yield $this->client->indexDocument('myindex', '', ['testField' => 'abc']);
echo $response['result']; // 'created'
});
See other usage examples in the tests/Integration/ClientTest.php
.
All client methods return an array representation of the ElasticSearch REST API responses in case of sucess or an Webgriffe\AmpElasticsearch\Error
in case of error.
The MIT License (MIT). Please see LICENSE
for more information.