2017 © Pedro Peláez
 

library elasticsearch-query-builder

image

sexlog/elasticsearch-query-builder

  • Wednesday, April 11, 2018
  • by rmartignoni
  • Repository
  • 2 Watchers
  • 9 Stars
  • 447 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 10 Versions
  • 4 % Grown

The README.md

sexlog/elasticsearch-query-builder

This is a library to query data from ElasticSearch. I have just started the development of this library and there is a lot to be done., (*1)

My aim is to communicate with ElasticSearch in a fully object oriented way., (*2)

Examples

Basic query


$hosts = ['10.0.0.10:9200']; $index = 'products'; $client = \Elasticsearch\ClientBuilder::fromConfig(['hosts' => $hosts]); $elasticSearch = new ElasticSearch\ElasticSearch($index, $client); // SELECT * FROM products WHERE product_name = 'ElasticSearch' LIMIT 4 $query = new ElasticSearch\Query(); $query->where('product_name', 'ElasticSearch'); $elasticSearch->setQuery($query) ->take(4) ->get(); // Paging results $results = $elasticSearch->page(1) ->get(); $results = $elasticSearch->page(2) ->get();

Query with a Filter


/* * SELECT id, product_name, price, updated_at * FROM products * WHERE product_name LIKE 'car%' AND category = 3 LIMIT 20 OFFSET 0 */ $query = new ElasticSearch\Query(); $query->wildcard('product_name', 'car*'); $filter = new ElasticSearch\Filter(); $filter->where('category', 3); // You should always use the take method before paging $elasticSearch->select('id, product_name, price, updated_at') ->setQuery($query) ->setFilter($filter) ->take(20) ->page(0) ->get(); // Paging $results = $elasticSearch->page(1) ->get();

Logging


$hosts = ['10.0.0.10:9200']; $index = 'products'; $client = \Elasticsearch\ClientBuilder::fromConfig(['hosts' => $hosts]); $elasticSearch = new ElasticSearch\ElasticSearch($index, $client); $errorHandler = new \Monolog\Handler\StreamHandler('elastic.log', \Monolog\Logger::ERROR); $logger = new \Monolog\Logger('elastic'); $logger->pushHandler($errorHandler); $elasticSearch->setLogger($logger);

The Versions

11/04 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni

11/04 2018

1.1.6

1.1.6.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni

17/08 2017

1.1.5

1.1.5.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni

17/08 2017

dev-definition-column-geo-distance

dev-definition-column-geo-distance

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni

15/08 2017

1.1.4

1.1.4.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni

17/03 2016

1.1.3

1.1.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni

27/01 2016

1.1.2

1.1.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni

27/01 2016

1.1.1

1.1.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni

27/01 2016

1.1.0

1.1.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni

18/01 2016

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Raphael Martignoni