2017 © Pedro Peláez
 

library ductible

Laravel and ElasticSearch in harmony.

image

krisanalfa/ductible

Laravel and ElasticSearch in harmony.

  • Friday, June 24, 2016
  • by krisanalfa
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Ductible

Ductible is a Laravel package that deliver a mid-level Elastic Search client., (*1)

Installation

You can install ductible via composer cli:, (*2)

composer install krisanalfa/ductible

Configuration

Register DuctibleServiceProvider to your configuration:, (*3)

'providers' => [
    // ...

    Zeek\Ductible\DuctibleServiceProvider::class,
],

Optional

Register Facade alias to your configuration:, (*4)

'aliases' => [
    // ...

    'Ductible' => Zeek\Ductible\Facades\Ductible::class,
],

Publishing Configuration

By default, you can use Ductible with zero configuration, assuming your Elasticsearch run in http://localhost:9200. If you want something different, you may publish Ductible configuration and make some changes from it:, (*5)

php artisan vendor:publish --provider="Zeek\Ductible\DuctibleServiceProvider"

Configuration Explained

You can read from inline docs there. It currently supports many aspect of Elasticsearch client configuration, such as:, (*6)

  • host (The most common configuration is telling the client about your cluster. read below to know how to configure multiple hosts.).
  • retries (When the client runs out of retries, it will throw the last exception that it received.).
  • log (Where to store your elasticsearch log.).
  • handler (Elasticsearch-PHP uses an interchangeable HTTP transport layer called RingPHP. You may customize your handler here.).
  • pool (The connection pool is an object inside the client that is responsible for maintaining the current list of nodes.).
  • selector (The connection pool manages the connections to your cluster.).
  • serializer (The response serializer.).
  • client.ignores (The library attempts to throw exceptions for common problems. These exceptions match the HTTP response code provided by Elasticsearch.)
  • client.verbose (If you require more information, you can tell the client to return a more verbose response.).

You can set multiple hosts by configuring in your env file like so:, (*7)

ELASTICSEARCH_HOSTS="localhost:9200|192.168.1.10:9200|http://myserver.com:9200"

Usage

Basic

Ductible provides a low level client interaction, which you can explore as much as you want., (*8)

Indexing a Document

$result = Ductible::index([
    'index' => 'myIndex',
    'type' => 'myType',
    'id' => 1,
    'body' => [
        'fieldFoo' => 'Foo',
        'fieldBar' => 'Bar',
        'fieldBaz' => 'Baz',
    ],
]);

Getting Document Index

$index = Ductible::get([
    'index' => 'myIndex',
    'type' => 'type',
    'id' => 1,
]); // The result is an array

Update Document Index

$result = Ductible::index([
    'index' => 'myIndex',
    'type' => 'myType',
    'id' => 1,
    'body' => [
        'fieldFoo' => 'Foo Foo',
        'fieldBar' => 'Bar Bar',
        'fieldBaz' => 'Baz Baz',
    ],
]);

Delete Document Index

$index = Ductible::delete([
    'index' => 'myIndex',
    'type' => 'type',
    'id' => 1,
]); // The result is an array

Searching

$result = Ductible::search($searchParams);

Bulk Indexing Documents

$result = Ductible::bulk($searchParams);

Using Eloquent

To Be Defined, (*9)

ToDo

  • [ ] Separate indexing operation based on eloquent model in Ductible main class
  • [ ] More unit testing

The Versions

24/06 2016

dev-develop

dev-develop

Laravel and ElasticSearch in harmony.

  Sources   Download

MIT

The Requires

 

The Development Requires

24/06 2016

dev-master

9999999-dev

Laravel and ElasticSearch in harmony.

  Sources   Download

MIT

The Requires

 

The Development Requires

24/06 2016
24/06 2016