myappin / elasticsearchpredicate
ElasticSearch nested predicate generator
8.0.2
2025-10-12 17:48 UTC
Requires
- php: >=8.1
- ext-curl: *
- elasticsearch/elasticsearch: v8.19.0
- myappin/knapsack: dev-master#e42820bbfe3315aeeec32a164882c5aba32b93b1
Requires (Dev)
- phpunit/phpunit: 9.5.6
This package is auto-updated.
Last update: 2026-06-16 11:17:35 UTC
README
ElasticSearchPredicate
is simple PHP API for ElasticSearch. It simulates Zend-Db predicates.
Please create issue while missing something or finding a bug
Install
composer: HERE OR
git clone https://github.com/myappin/ElasticSearchPredicate.git
Usage
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