Simple and easy to use wrapper for the official Elasticsearch PHP Client.
Via Composer
$composer require iivannov/elastic-commander
// minimum required
$commander = new Commander('YourIndexName');
// with a list of hosts
$commander = new Commander('YourIndexName', $hosts);
$commander->index()->create()
$commander->index()->delete()
A helper method that will reset the index by deleting it and creating it again.
$commander->index()->reset()
// Not finished
$commander->index()->optimize()
// Not finished
$commander->index()->stats()
$commander->document('SomeDocumentType')->exists($id)
$commander->document('SomeDocumentType')->get($id)
In current version the add method expects an ID for the document.
$commander->document('SomeDocumentType')->add($id, $parameters)
$commander->document('SomeDocumentType')->add($id, $parameters)
Searching is done by passing a raw query array or by using a custom criteria class. After the query you have the option to get: the full response, only the ids, a map of the results or the total count.
$commander->search('SomeDocumentType')->query($query, $sort, $size, $from)
$commander->search('SomeDocumentType')->criteria($criteria)