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 2mo ago

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

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

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

2416d 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://www.gravatar.com/avatar/e06b59037015976fdaffbf88e4bc073b064f1bab21cf13b3fa9bfca7c13adca5?d=identicon)[galexth](/maintainers/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.

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

Next-gen Elasticsearch driver for Laravel Scout.

397612.3k](/packages/jeroen-g-explorer)[jolicode/elastically

Opinionated Elastica based framework to bootstrap PHP and Elasticsearch implementations.

2571.7M1](/packages/jolicode-elastically)[mmanos/laravel-search

A search package for Laravel 5.

36475.7k1](/packages/mmanos-laravel-search)[baijunyao/laravel-scout-elasticsearch

Elasticsearch Driver for Laravel Scout

8023.7k1](/packages/baijunyao-laravel-scout-elasticsearch)[kunstmaan/search-bundle

The KunstmaanSearchBundle works with ElasticSearch and supports different search providers. The bundle currently supports Elastica as a provider. Add your own objects to index using a tagged service which implements the SearchConfigurationInterface

1884.8k1](/packages/kunstmaan-search-bundle)

PHPackages © 2026

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