PHPackages                             spameri/elastic-query - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. spameri/elastic-query

ActiveLibrary

spameri/elastic-query
=====================

Objects instead of arrays for querying to ElasticSearch.

v1.0.1(2y ago)643.1k↑85.7%4[1 issues](https://github.com/Spameri/ElasticQuery/issues)1PHPPHP &gt;=7.4

Since Oct 19Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Spameri/ElasticQuery)[ Packagist](https://packagist.org/packages/spameri/elastic-query)[ RSS](/packages/spameri-elastic-query/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (37)Used By (1)

ElasticQuery
============

[](#elasticquery)

A PHP library that converts Elasticsearch query DSL into strongly-typed PHP objects. Instead of building queries as arrays, use type-safe classes that mirror the Elasticsearch documentation.

Features
--------

[](#features)

- **Type-safe queries** - Full-text, term-level, compound, geo, and nested queries
- **Aggregations** - Metric (min, max, avg) and bucket (terms, histogram, range, filter) aggregations
- **Response mapping** - Automatic mapping of Elasticsearch responses to typed objects
- **Index mapping** - Define index settings, analyzers, tokenizers, and filters
- **Function scoring** - Custom scoring with field value factors, weights, and random scores
- **Highlighting** - Search result highlighting support
- **Pagination &amp; sorting** - Options for size, offset, scroll, and geo-distance sorting

Requirements
------------

[](#requirements)

- PHP 8.2 or higher

Installation
------------

[](#installation)

Install via [Composer](http://getcomposer.org/):

```
composer require spameri/elastic-query
```

Quick Start
-----------

[](#quick-start)

```
use Spameri\ElasticQuery\ElasticQuery;
use Spameri\ElasticQuery\Query\ElasticMatch;
use Spameri\ElasticQuery\Query\Term;

// Create a query
$query = new ElasticQuery();

// Add a must query (AND condition)
$query->addMustQuery(new ElasticMatch('title', 'Elasticsearch'));

// Add a filter (cached, no scoring)
$query->addFilter(new Term('status', 'published'));

// Set pagination
$query->options()->changeSize(10);
$query->options()->changeFrom(0);

// Convert to array for Elasticsearch client
$body = $query->toArray();
```

Documentation
-------------

[](#documentation)

Learn more in the [documentation](https://github.com/Spameri/ElasticQuery/tree/master/doc):

- [Usage](https://github.com/Spameri/ElasticQuery/tree/master/doc/01-usage.md) - Integration examples
- [Query Objects](https://github.com/Spameri/ElasticQuery/tree/master/doc/02-query-objects.md) - All query types
- [Aggregation Objects](https://github.com/Spameri/ElasticQuery/tree/master/doc/03-aggregation-objects.md) - Aggregation types
- [Result Objects](https://github.com/Spameri/ElasticQuery/tree/master/doc/04-result-objects.md) - Response mapping
- [Options &amp; Sorting](https://github.com/Spameri/ElasticQuery/tree/master/doc/05-options.md) - Pagination, sorting, scroll
- [Highlight &amp; Function Score](https://github.com/Spameri/ElasticQuery/tree/master/doc/06-highlight-function-score.md) - Highlighting and custom scoring
- [Mapping &amp; Settings](https://github.com/Spameri/ElasticQuery/tree/master/doc/07-mapping-settings.md) - Index configuration

License
-------

[](#license)

MIT

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance56

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 98% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~62 days

Recently: every ~226 days

Total

35

Last Release

641d ago

Major Versions

v0.6.0-beta → v1.0.0-alpha2020-09-20

v1.0.1 → v2.0.0-alpha2024-06-09

PHP version history (3 changes)v0.1.0PHP &gt;=7.1

v1.0.0-alpha.11PHP &gt;=7.4

v2.0.0-alphaPHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/114232067?v=4)[VBoss](/maintainers/VBoss)[@Vboss](https://github.com/Vboss)

---

Top Contributors

[![Spamercz](https://avatars.githubusercontent.com/u/1753937?v=4)](https://github.com/Spamercz "Spamercz (195 commits)")[![AloisJasa](https://avatars.githubusercontent.com/u/17596051?v=4)](https://github.com/AloisJasa "AloisJasa (2 commits)")[![Jakub-Fajkus](https://avatars.githubusercontent.com/u/13538235?v=4)](https://github.com/Jakub-Fajkus "Jakub-Fajkus (1 commits)")[![pechondra](https://avatars.githubusercontent.com/u/21057847?v=4)](https://github.com/pechondra "pechondra (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spameri-elastic-query/health.svg)

```
[![Health](https://phpackages.com/badges/spameri-elastic-query/health.svg)](https://phpackages.com/packages/spameri-elastic-query)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
