Skip to content

PHPFluent/ElasticQueryBuilder

Repository files navigation

ElasticQueryBuilder

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads License

A fluent query builder for Elastic Search.

Installation

Package is available on Packagist, you can install it using Composer.

composer require phpfluent/elastic-query-builder

PHP 5.5+ or HHVM 3.5+ are required.

Usage

$builder = new Query();
$builder->query()->filtered()->query()->matchAll(new stdClass());
$builder->query()->filtered()->filter()->and(
    [
        new Term('my.nested.label', 'my_value'),
        new Term('my_label', 'other_value'),
    ]
);

echo $builder.PHP_EOL;

The result of the code above is:

{"query":{"filtered":{"query":{"match_all":{}},"filter":{"and":[{"term":{"my.nested.label":"my_value"}},{"term":{"my_label":"other_value"}}]}}}}