<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
edwinhoksberg / elasticsearch-query-builder example snippets
use EdwinHoksberg\ElasticsearchQueryBuilder\Aggregations\MaxAggregation;
use EdwinHoksberg\ElasticsearchQueryBuilder\Builder;
use EdwinHoksberg\ElasticsearchQueryBuilder\Queries\MatchQuery;
$client = Elastic\Elasticsearch\ClientBuilder::create()->build();
$companies = (new Builder($client))
->index('companies')
->addQuery(MatchQuery::create('name', 'spatie', fuzziness: 3))
->addAggregation(MaxAggregation::create('score'))
->search();
use EdwinHoksberg\ElasticsearchQueryBuilder\Queries\RangeQuery;
use EdwinHoksberg\ElasticsearchQueryBuilder\Builder;
$client = Elastic\Elasticsearch\ClientBuilder::create()->build();
$builder = new Builder($client);
$builder->addQuery(RangeQuery::create('age')->gte(18));
$results = $builder->search(); // raw response from ElasticSearch