PHPackages                             pskordilakis/elastin - 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. pskordilakis/elastin

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

pskordilakis/elastin
====================

Elasticsearch Query Builder

v0.1.12(7y ago)290MITPHPPHP ^7.2

Since Oct 18Pushed 7y ago1 watchersCompare

[ Source](https://github.com/pskordilakis/elastin)[ Packagist](https://packagist.org/packages/pskordilakis/elastin)[ Docs](https://github.com/pskordilakis/elastin)[ RSS](/packages/pskordilakis-elastin/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (16)Used By (0)

Elastin
=======

[](#elastin)

Elasticsearch query builder. Intended to be used with [elasticsearch-php](https://github.com/elastic/elasticsearch-php) official client.

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

[](#installation)

```
composer require pskordilakis/elastin
```

Usage
-----

[](#usage)

### Create builder instance

[](#create-builder-instance)

```
use Elastin\Builder;

$builder = Builder::create();
```

### Set index/indices

[](#set-indexindices)

```
$builder->index('index_1')
```

or

```
$builder->indices(['index_2', 'index_3']);
```

### Add bool query

[](#add-bool-query)

Supported bool queries: must, filter, mustNot, should

```
$builder->filter('term', [ 'tag' => 'search' ]);
```

### Aggregations

[](#aggregations)

Add simple aggregations to query

```
$builder->aggregation('aggregation_name', [ 'aggregation_type' => $aggregation_body ]);
```

Nested aggregation supported by defining a dot separated name

```
$builder->aggregation('parent_aggregation_path.aggregation_name', [ 'aggregation_type' => $aggregation_body ]);
```

### Build query

[](#build-query)

Build method return an array representation of query that can be past to elasticsearch-php client.

```
$query = $builder->build();

$client->search($query);
```

Aliases
-------

[](#aliases)

Some aliases are provided for common cases.

Aggregation aliases can be used as nested aggregations by passing a dot separated path in name parameter.

### Where

[](#where)

Define a term filter

```
$builder->where($field, $value);
```

### WhereBetween

[](#wherebetween)

Define a range filter

```
$builder->whereBetween($field, $gte, $lte);
```

### Count

[](#count)

Create a value\_count aggregation

```
$builder->count($name, $field);
```

### Cardinality

[](#cardinality)

Create a cardinality aggregation

```
$builder->cardinality($name, $field);
```

### GroupBy

[](#groupby)

Create a term aggregation

```
$builder->groupBy($name, $field);
```

### TimeSeries

[](#timeseries)

Create a date\_histogram aggregation

```
$builder->timeSeries($name, $field, $options);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.2% 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 ~12 days

Recently: every ~31 days

Total

15

Last Release

2579d ago

PHP version history (2 changes)v0.0.1PHP ^7.1

v0.1.6PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/edb2d1fc71976a6f3bb2ac6ddc18b6b2e02a0082a0a4339b0f816f368907853d?d=identicon)[pskordilakis](/maintainers/pskordilakis)

---

Top Contributors

[![pskordilakis](https://avatars.githubusercontent.com/u/15627750?v=4)](https://github.com/pskordilakis "pskordilakis (25 commits)")[![hatwheels](https://avatars.githubusercontent.com/u/12772651?v=4)](https://github.com/hatwheels "hatwheels (1 commits)")

---

Tags

elasticsearchquerybuilder

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pskordilakis-elastin/health.svg)

```
[![Health](https://phpackages.com/badges/pskordilakis-elastin/health.svg)](https://phpackages.com/packages/pskordilakis-elastin)
```

###  Alternatives

[netgen/query-translator

Query Translator is a search query translator with AST representation

2042.0M6](/packages/netgen-query-translator)[minimalcode/search

Fluent Lucene-Sorl Query Builder for PHP

26501.8k6](/packages/minimalcode-search)

PHPackages © 2026

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