elastification/php-client

The elastification php client aims to be a very flexible and well performing client to elasticsearch. It supports multiple transports and serializers to maximize it's flexibility.

0.14.2 2016-03-30 08:49 UTC

README

Build Status Scrutinizer Code Quality Code Coverage Dependency Status

Latest Stable Version Total Downloads Latest Unstable Version License

SensioLabsInsight

ToDo

  • Helper for Version response compare. (Symfony/Console)
  • singular _alias Put/Post/delete/head (v1,v2?)
  • GetFieldMappingRequest (seems to be only in v1 and v2)
  • cat api (v1, v2, check if v90)
  • repository for cat (implement version check 1 and 2 only)
  • analyze (v1, v2, check if v90)
  • snapshot (v1, v2, check if v90)
  • index recovery (v1, v2, check if v90)
  • Think about an array of clients or a decision manager for get the right client (maybe voter pattern?)
  • Write documentation
  • Create Github Pages
  • Check all requests and write down missing here

Changes from Version 1x to 2x

  • NodeInfo does not have status in response
  • DeleteByQuery is removed
  • DeleteMapping is removed
  • Index/IndexStats is removed (replaced by index stats)
  • Bulk/BulkInsertRequest existing documents having new a subobject under item['error'] response
  • Bulk/BulkUpdateRequest existing documents having new a subobject under item['error'] response

Testing

The tests are devided into unit tests and integration tests.

Running the unit tests is simple (composer install is reqired):

    bin/phpunit tests/Unit

If you like coder coverage it will be placed in build folder:

    bin/phpunit --coverage-html=build tests/Unit

There are also integration test. The subfolders holding version tests. There is a vagrant repository where you can bring all wanted/needed machine alive. [Link is missing]

The phpunit-integration.xml has defined constants for each testable version.

Run integration tests for v2x versions looks like this:

    bin/phpunit --coverage-html=build -c phpunit-integration.xml tests/Integration/Request/V2x

Requests Examples

How to check if indexExists:

$indexExistsRequest = new IndexExistsRequest('index', null, $this->serializer);

try {
    $client->send($indexExistsRequest);
    return true;
} catch(ClientException $exception) {
    return false;
}

How to check if indexTypeExists:

$indexTypeExistsRequest = new IndexTypeExistsRequest('index', 'type', $this->serializer);

try {
    $client->send($indexTypeExistsRequest);
    return true;
} catch(ClientException $exception) {
    return false;
}