Laravel and ElasticSearch in harmony.
Open Issues: 0
- doctrine/dbal: ^2.5
- elasticsearch/elasticsearch: ~2.2
- laravel/laravel: ~5.1
- fzaninotto/faker: ^1.6
- phpunit/phpunit: ^5.4
This package is auto-updated.
Last update: 2023-05-29 00:51:08 UTC
Ductible is a Laravel package that deliver a mid-level Elastic Search client.
You can install ductible via composer cli:
composer install krisanalfa/ductible
DuctibleServiceProvider to your configuration:
'providers' => [ // ... Zeek\Ductible\DuctibleServiceProvider::class, ],
Register Facade alias to your configuration:
'aliases' => [ // ... 'Ductible' => Zeek\Ductible\Facades\Ductible::class, ],
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:
php artisan vendor:publish --provider="Zeek\Ductible\DuctibleServiceProvider"
You can read from inline docs there. It currently supports many aspect of Elasticsearch client configuration, such as:
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:
Ductible provides a low level client interaction, which you can explore as much as you want.
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
$result = Ductible::search($searchParams);
Bulk Indexing Documents
$result = Ductible::bulk($searchParams);
To Be Defined
- Separate indexing operation based on eloquent model in Ductible main class
- More unit testing