PHPackages                             xpd1437/elastic - 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. [Database &amp; ORM](/categories/database)
4. /
5. xpd1437/elastic

ActiveLibrary[Database &amp; ORM](/categories/database)

xpd1437/elastic
===============

Use SQL statements to query elastic

1.0.0(5y ago)13MITPHPPHP &gt;=7.0

Since Dec 8Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/allesx/elastic)[ Packagist](https://packagist.org/packages/xpd1437/elastic)[ Docs](https://github.com/xpd1437/elastic)[ RSS](/packages/xpd1437-elastic/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Allesx Elastic
==============

[](#allesx-elastic)

[![Latest Stable Version](https://camo.githubusercontent.com/a5685cd31b986bae39b8a55c23313a2e92b0d600b320e93244279e45f18a399f/68747470733a2f2f706f7365722e707567782e6f72672f616c6c6573782f656c61737469632f762f737461626c65)](https://packagist.org/packages/allesx/elastic)[![License](https://camo.githubusercontent.com/3a0951d9a0a9e8587120c1b2aa41cc69efcd230a2c0d48c6b257298f2ab336cc/68747470733a2f2f706f7365722e707567782e6f72672f616c6c6573782f656c61737469632f6c6963656e7365)](https://packagist.org/packages/allesx/elastic)

Version Matrix
--------------

[](#version-matrix)

Elastic Versionallesx/elastic Branch&gt;= 6.01.\*&gt;= 5.0, &lt; 6.00.\*Install
-------

[](#install)

You can install the package via composer:

```
composer require allesx/elastic

```

Laravel
-------

[](#laravel)

Modify `config / app.php`

```
'providers' => [
    Allesx\Elastic\LaravelServiceProvider::class,
]

```

If you'd like to make configuration changes in the configuration file you can pubish it with the following Aritsan command:

```
php artisan vendor:publish --provider="Allesx\Elastic\LaravelServiceProvider"

```

Quickstart
----------

[](#quickstart)

### Create

[](#create)

```
Route::get('test/create',function(\Allesx\Elastic\Builder $builder){
    $result = $builder->index('index')->type('type')->create([
		'key' => 'value',
    ]);
    dump($result);
});
```

### Update

[](#update)

```
Route::get('test/create',function(\Allesx\Elastic\Builder $builder){
    $result = $builder->index('index')->type('type')->update('id',[
		'key' => 'value2',
    ]);
    dump($result);
});
```

### Delete

[](#delete)

```
Route::get('test/create',function(\Allesx\Elastic\Builder $builder){
    $result = $builder->index('index')->type('type')->delete('id');
    dump($result);
});
```

### Select

[](#select)

```
Route::get('test/create',function(\Allesx\Elastic\Builder $builder){
    $builder = $builder->index('index')->type('type');

	//SQL:select ... where id = 1 limit 1;
	$result = $builder->whereTerm('id',1)->first();

	//SQL:select ... where (key=1 or key=2) and key1=1
	$result = $builder->where(function (Builder $inQuery) {
		$inQuery->whereTerm('key',1)->orWhereTerm('key',2)
	})->whereTerm('key1',1)->get();

});
```

### More

[](#more)

skip / take

```
$builder->take(10)->get(); // or limit(10)
$builder->offset(10)->take(10)->get(); // or skip(10)
```

term query

```
$builder->whereTerm('key',value)->first();
```

match query

```
$builder->whereMatch('key',value)->first();
```

range query

```
$builder->whereBetween('key',[value1,value2])->first();
```

where in query

```
$builder->whereIn('key',[value1,value2])->first();
```

logic query

```
$builder->whereTerm('key',value)->orWhereTerm('key2',value)->first();
```

nested query

```
$result = $builder->where(function (Builder $inQuery) {
    $inQuery->whereTerm('key',1)->orWhereTerm('key',2)
})->whereTerm('key1',1)->get();
```

### Available conditions

[](#available-conditions)

```
public function select($columns): self
```

```
public function where($column, $operator = null, $value = null, $leaf = 'term', $boolean = 'and'): self
```

```
public function orWhere($field, $operator = null, $value = null, $leaf = 'term'): self
```

```
public function whereMatch($field, $value, $boolean = 'and'): self
```

```
public function orWhereMatch($field, $value, $boolean = 'and'): self
```

```
public function whereTerm($field, $value, $boolean = 'and'): self
```

```
public function whereIn($field, array $value)
```

```
public function orWhereIn($field, array $value)
```

```
public function orWhereTerm($field, $value, $boolean = 'or'): self
```

```
public function whereRange($field, $operator = null, $value = null, $boolean = 'and'): self
```

```
public function orWhereRange($field, $operator = null, $value = null): self
```

```
public function whereBetween($field, array $values, $boolean = 'and'): self
```

```
public function orWhereBetween($field, array $values): self
```

```
public function orderBy(string $field, $sort): self
```

```
public function scroll(string $scroll): self
```

```
public function aggBy($field, $type): self
```

```
public function select($columns): self
```

### Result Method

[](#result-method)

```
public function get(): Collection
```

```
public function paginate(int $page, int $perPage = 15): Collection
```

```
public function first()
```

```
public function byId($id)
```

```
public function byIdOrFail($id): stdClass
```

```
public function chunk(callable $callback, $limit = 2000, $scroll = '10m')
```

```
public function create(array $data, $id = null, $key = 'id'): stdClass
```

```
public function update($id, array $data): bool
```

```
public function delete($id)
```

```
public function count(): int
```

### Log

[](#log)

```
//open log
$builder->enableQueryLog();

//all query log
dump($build->getQueryLog());

//last query log
dump($build->getLastQueryLog());
```

### Elastisearch object

[](#elastisearch-object)

```
getElasticSearch() // or search()
```

License
-------

[](#license)

[MIT license](https://opensource.org/licenses/MIT)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1987d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/20893455fcae0521e82872aa48a60c26b697bc329921925f41419335c4763f84?d=identicon)[allesx](/maintainers/allesx)

---

Top Contributors

[![allesx](https://avatars.githubusercontent.com/u/1401166?v=4)](https://github.com/allesx "allesx (6 commits)")

---

Tags

phplaravelormsqlelastic

### Embed Badge

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

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

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)[crcms/elasticsearch

Use SQL statements to query elasticsearch

1058.3k1](/packages/crcms-elasticsearch)[matchory/elasticsearch

The missing elasticsearch ORM for Laravel!

3059.0k](/packages/matchory-elasticsearch)[ymigval/laravel-model-cache

Laravel package for caching Eloquent model queries

7642.2k3](/packages/ymigval-laravel-model-cache)[crcms/repository

Detached model and controller warehouse data provider

674.4k3](/packages/crcms-repository)

PHPackages © 2026

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