is simple PHP API for ElasticSearch. It simulates Zend-Db predicates.
Please create issue while missing something or finding a bug
composer: HERE OR
git clone https://github.com/myappin/ElasticSearchPredicate.git
Adding predicates
addPredicate(PredicateInterface $predicate)
, andPredicate(PredicateInterface $predicate)
, orPredicate(PredicateInterface $predicate)
, and(PredicateInterface $predicate)
, or(PredicateInterface $predicate)
Basic predicates
$_client = new Client();
$_search = $_client->search();
$_search->limit(10)->order('_uid', 'asc')->predicate->Term('name', 'SomeName')->or->Term('price', 1000);
Nesting
$_client = new Client();
$_search = $_client->search();
$_search->limit(10)->order('_uid', 'asc')->predicate->nest()->Term('name', 'SomeName')->or->Term('name', 'SomeOtherName')->unnest()->Term('price', 1000);
Boosting
$_client = new Client();
$_search = $_client->search();
$_search->limit(10)->order('_uid', 'asc')->predicate->andPredicate((new Term('name', 'SomeName'))->boost(2))->or->Term('name', 'SomeOtherName');
//or
$_search->limit(10)->order('_uid', 'asc')->predicate->Term('name', 'SomeName', ['boost' => 2])->or->Term('name', 'SomeOtherName');
Nested objects, Ranges, Score Functions and more and more