PHPackages                             galexth/elasticsearch-querybuilder - 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. [Search &amp; Filtering](/categories/search)
4. /
5. galexth/elasticsearch-querybuilder

ActiveLibrary[Search &amp; Filtering](/categories/search)

galexth/elasticsearch-querybuilder
==================================

elasticsearch querybuilder

v1.2.8(6y ago)0232MITPHPPHP &gt;=7.1.3|^7.2CI failing

Since Aug 11Pushed 6y ago1 watchersCompare

[ Source](https://github.com/galexth/elasticsearch-querybuilder)[ Packagist](https://packagist.org/packages/galexth/elasticsearch-querybuilder)[ RSS](/packages/galexth-elasticsearch-querybuilder/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (8)Versions (26)Used By (0)

Elasticsearch query builder
===========================

[](#elasticsearch-query-builder)

Elastica query builder for laravel.

Rules
-----

[](#rules)

Each rules have to implement \\Galexth\\QueryBuilder\\Rule interface with pattern() array:

```
class MyRule implements Rule
{
    public function patterns(): array
    {
        return [
            [
                'name' => 'location.country', // name of the field in the query (@location.country has ....)
                'query_type' => 'terms', // query type (terms, term, match, multi_match, etc...)
                'fields' => ['locations.country'], // fields to search in
                // nested if necessary
                'nested' => [
                    'path' => 'locations'
                ],
                'type' => 'text', // value type (text, integer, date), text is only supported by now
            ],
            // custom handler
            [
                'name' => 'persona',
                'query_type' => 'custom',
                'fields' => ['persona_id'],
                'type' => 'text',
                'callback' => function ($values) {
                    $bool = new BoolQuery();
                    return $bool->addFilter(new Terms('asd', (array) $values));
                }
            ],
            // using a regular expressions
            [
                'name' => 'rank\.(?[\w-_]+)$',
                'expression' => true,
                'query_type' => 'terms',
                'fields' => ['ranks.{sub_field}'],
                'type' => 'text',
            ],
            ...
        ];
    }
}
```

Query
-----

[](#query)

Use queries like:

```
$query = '@name is Prof. Johan Schoen and @industry is Network Security Hardware & Software';
$query = '@name is "John" and @industry is \'Medicine\' or (@industry is Oil and @name is Chris) or @name is Jesus';
$query = '@revenue gte 123 and @revenue lt 523';
...
```

More examples could be found in tests.

```
    $builder = new Builder(new MyRule);

    $bool = $builder->build($query); // BoolQuery
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~17 days

Recently: every ~51 days

Total

25

Last Release

2465d ago

Major Versions

v0.8 → v1.02018-08-13

PHP version history (2 changes)v0.8PHP &gt;=7.1.3

v1.2.7PHP &gt;=7.1.3|^7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10194439?v=4)[Alex G](/maintainers/galexth)[@galexth](https://github.com/galexth)

---

Top Contributors

[![galexth](https://avatars.githubusercontent.com/u/10194439?v=4)](https://github.com/galexth "galexth (41 commits)")

---

Tags

elasticsearchquerybuilder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/galexth-elasticsearch-querybuilder/health.svg)

```
[![Health](https://phpackages.com/badges/galexth-elasticsearch-querybuilder/health.svg)](https://phpackages.com/packages/galexth-elasticsearch-querybuilder)
```

###  Alternatives

[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

935572.3k2](/packages/mailerlite-laravel-elasticsearch)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

399654.3k](/packages/jeroen-g-explorer)[heyday/silverstripe-elastica

Provides Elastic Search integration for SilverStripe DataObjects using Elastica

1137.9k2](/packages/heyday-silverstripe-elastica)

PHPackages © 2026

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