nanawel / amp-elasticsearch

A non-blocking ElasticSearch client for PHP based on Amp. Fork of webgriffe/amp-elasticsearch.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Amp ElasticSearch Client

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+.

⚠️ Backward incompatible changes:

  • \Webgriffe\AmpElasticsearch\Client::existsIndex() returns false 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


Build Status

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.

License

The MIT License (MIT). Please see LICENSE for more information.

About

A non-blocking ElasticSearch client for PHP based on Amp. Fork of webgriffe/amp-elasticsearch.

License:MIT License


Languages

Language:PHP 100.0%