naresh/elasticsearchclient

ElasticSearch client library with amazon elasticsearch PHP signing handler

1.0.1 2018-03-13 05:46 UTC

This package is not auto-updated.

Last update: 2024-10-03 00:09:36 UTC


README

ElasticSearch client library with amazon elasticsearch PHP signing handler. This library is targeted for laravel but can also be used with other frameworks.

Installation

Require package in composer.json file.

    "require":{
        "naresh/elasticsearchclient": "1.0.*",
    }

And run composer update to update the dependency.

Configuration (Laravel Only)

NOTE: You do not have to add ServerProvider and Facade if you are using Laravel 5.5 package autodiscovery.

  • Add the ServiceProvider to the providers array in config/app.php

    Naresh\ElasticSearchClient\ServiceProvider::class

  • Add EsClient Facade in config/app.php

    'EsClient' => Naresh\ElasticSearchClient\Facade\EsClient::class,

Usage

You can get the new Elasticsearch instance in two ways

1) With EsClient Facade (Laravel Only)

* `EsClient::getClient($options)`

2) With new instance of Naresh\ElasticSearchClient\ElasticSearchClient

* `new ElasticSearchClient($options)`

$options

 [
    'hosts' => [],
    'aws_host' => false,
    'access_key' => '',
    'secret_key' => '',
    'region' => ''
];
  • hosts (array)

    • Elasticsearch host(s)
  • aws_host (boolean)

    • Boolean flag to specify if the hostname is AWS Elasticsearch service, however if your host has amazonaws in its URL then you dont have to add this flag, this library will assume it as AWS Elasticsearch service
  • access_key(string only needed if host is AWS Elasticsearch service)

    • AWS Elasticsearch service access key
  • secret_key(string only needed if host is AWS Elasticsearch service)

    • AWS Elasticsearch service secret key
  • region(string only needed if host is AWS Elasticsearch service)

    • AWS Elasticsearch service region

Run tests

Run unit test with phpunit following command.

    vendor/bin/phpunit -v

It will generate test coverage reports in reports folder