Simple PHP client for ElasticSearch
Pull request Compare This branch is 81 commits behind nervetattoo:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
src/ElasticSearch
tests
.gitignore
.travis.yml
LICENSE
README.markdown
composer.json
phpunit.xml

README.markdown

Build Status

ElasticSearch PHP client

ElasticSearch is a distributed lucene powered search indexing, this is a PHP client for it

Basic usage

<?php
use \ElasticSearch\Client;
// The recommended way to go about things is to use an environment variable called ELASTICSEARCH_URL
$es = Client::connection();

// Alternatively you can use dsn string
$es = Client::connection('http://127.0.0.1:9200/myindex/mytype');

$es->index(array('title' => 'My cool document'), $id);
$es->get($id);
$es->search('title:cool');

Search multiple indexes or types

<?php
$es->setIndex(array("one", "two"));
$es->setType(array("mytype", "other-type"));
$es->search('title:cool');

Using the Query DSL

<?php
$es->search(array(
    'query' => array(
        'term' => array('title' => 'cool')
    )
);

Provide configuration as array

Using an array for configuration also works

<?php
$es = Client::connection(array(
    'server' => '127.0.0.1:9200',
    'protocol' => 'http',
    'index' => 'myindex',
    'type' => 'mytype'
));