Download the PHP package bonu/php-elasticsearch-builder without Composer
On this page you can find all versions of the php package bonu/php-elasticsearch-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bonu/php-elasticsearch-builder
More information about bonu/php-elasticsearch-builder
Files in bonu/php-elasticsearch-builder
Package php-elasticsearch-builder
Short Description Elasticsearch query builder for PHP
License MIT
Informations about the package php-elasticsearch-builder
PHP Query Builder for Elasticsearch
A clean, fluent, immutable, and type-safe query builder for Elasticsearch - built from the ground up to work seamlessly with the official Elasticsearch PHP client.
No extra dependencies. No magic. Just expressive, readable, and maintainable Elasticsearch queries in PHP.
Features
- Fully fluent & chainable API
- Zero dependencies beyond the official Elasticsearch PHP SDK
- Easy creation of reusable composite queries
- 100% type-hinted and IDE-friendly
Requirements
- PHP ≥ 8.4
Installation
Using query builder
The Bonu\ElasticsearchBuilder\QueryBuilder class provides a fluent interface for building Elasticsearch queries.
Constructor of this class accepts a single argument - name of the index to query, which may be used for searching in specific index.
Out of box it supports:
- Chaining queries using
query()method - Chaining aggregations using
aggregation()method - Configuring pagination of results using
from()andsize()methods
Queries
[!CAUTION] Queries are immutable.
This package comes with a set of ready-to-use queries which is documented below.
It is also possible to create reusable composite queries using abstract Bonu\ElasticsearchBuilder\Query\CompositeQuery class.
Example of composite query:
TermQuery
https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-term-query
TermsQuery
https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-terms-query
ExistsQuery
https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-exists-query
MatchQuery
https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-match-query
MatchPhraseQuery
https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-match-query-phrase
BoolQuery
https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-bool-query
NestedQuery
https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-nested-query
RangeQuery
https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-range-query
Range queries can be used for filtering by multiple data types. For this reason, each data type has its own query class to fully support type-hinting.
Aggregations
[!CAUTION] Aggregations are immutable.
Similar to queries, it is also possible to create reusable composite aggregations using abstract Bonu\ElasticsearchBuilder\Aggregation\CompositeAggregation class.
Example of composite aggregation:
ContainerAggregation
Container aggregation is used to group sub-aggregations. It requires either global or at least one filter (query) to be set, but not both.
TermsAggregation
https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-terms-aggregation
StatsAggregation
https://www.elastic.co/docs/reference/aggregations/search-aggregations-metrics-stats-aggregation
NestedAggregation
https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-nested-aggregation
MultiTermsAggregation
HistogramAggregation
https://www.elastic.co/docs/reference/aggregations/search-aggregations-bucket-histogram-aggregation
<<<<<<< HEAD
SumAggregation
https://www.elastic.co/docs/reference/aggregations/search-aggregations-metrics-sum-aggregation
CardinalityAggregation
DateHistogramAggregation
Sorts
FieldSort
ScoreSort
License
This package is licensed under the MIT License.