What is Sherlock?

Sherlock is a PHP (>=5.3.0) client for ElasticSearch Sherlock provides an easy, simple interface to search and manage your ElasticSearch cluster.


Sherlock aims to continue the precendent set by ElasticSearch: work out of the box with minimal configuration and provide a simple interface.

The developer should never need to stop and look up a class name to instantiate, or dig through docs to remember which class accepts which arguments.


While Sherlock provides a powerful ORM-like interface to managing ElasticSearch, we recognize that an ORM is not always convenient.

Where possible, Sherlock methods are compatible with raw associative arrays, or even plain JSON. Use as much, or as little, of the ORM as you need.

Fork on Github
//Build a new search request
$request = $sherlock->search();
//populate a Term query to start
$termQuery = Sherlock::queryBuilder()->Term()

//Set the index, type and from/to parameters of the request.

//Execute the search and return results
$response = $request->execute();
echo "Took: ".$response->took."\r\n";
echo "Number of Hits: ".count($response)."\r\n";

//Iterate over the hits and print out some data
foreach($response as $hit)
    echo $hit['score'].' - '.$hit['source']['message']."\r\n";