2017 © Pedro Peláez
 

library elasticsearch-query-builder

Create elastic search query with a fluent interface

image

erichard/elasticsearch-query-builder

Create elastic search query with a fluent interface

  • Thursday, July 26, 2018
  • by erichard
  • Repository
  • 1 Watchers
  • 6 Stars
  • 3,443 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 5 Versions
  • 65 % Grown

The README.md

ElasticSearch Query Builder

img php, (*1)

This is a PHP library which helps you build query for an ElasticSearch client by using a fluent interface., (*2)

WARNING: This branch contains the next 3.x release. Check the corresponding issue for the roadmap., (*3)

Installation

composer require erichard/elasticsearch-query-builder "^3.0@beta"

Usage


use Erichard\ElasticQueryBuilder\QueryBuilder; use Erichard\ElasticQueryBuilder\Aggregation\Aggregation; use Erichard\ElasticQueryBuilder\Filter\Filter; $qb = new QueryBuilder(); $qb ->setIndex('app') ->setSize(10) ; // Add an aggregation $qb->addAggregation(Aggregation::terms('agg_name', 'my_field')); $qb->addAggregation(Aggregation::terms('agg_name_same_as_field')); // Set query $qb->setQuery(Query::terms('field', 'value')); // I am using a client from elasticsearch/elasticsearch here $results = $client->search($qb->build());

with PHP 8.1 you can use named arguments like this:, (*4)

$query = new BoolQuery(must: [
    new RangeQuery(
        field: 'price',
        gte: 100
    ),
    new RangeQuery(
        field: 'stock',
        gte: 10
    ),
]);

or with the factory, (*5)

$query = Query::bool(must: [
    Query::range(
        field: 'price',
        gte: 100
    ),
    Query::range(
        field: 'stock',
        gte: 10
    ),
]);

Contribution

  • Use PHPCS fixer and PHPStan
    • composer lint
  • Update tests (PHPUnit)
    • composer test

The Versions

26/07 2018

dev-master

9999999-dev

Create elastic search query with a fluent interface

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Erwan Richard

05/06 2018

v2.1

2.1.0.0

Create elastic search query with a fluent interface

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Erwan Richard

09/03 2018

v2.0.0

2.0.0.0

Create elastic search query with a fluent interface

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Erwan Richard

09/02 2018

v1.0.1

1.0.1.0

Create elastic search query with a fluent interface

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Erwan Richard

07/02 2018

v1.0.0

1.0.0.0

Create elastic search query with a fluent interface

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Erwan Richard