PHPackages                             crcms/elasticsearch - 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. crcms/elasticsearch

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

crcms/elasticsearch
===================

Use SQL statements to query elasticsearch

1.0.2(6y ago)1028.3k151MITPHPPHP &gt;=7.0CI failing

Since Oct 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/crcms/elasticsearch)[ Packagist](https://packagist.org/packages/crcms/elasticsearch)[ Docs](https://github.com/crcms/elasticsearch) Fund Fund[ RSS](/packages/crcms-elasticsearch/feed)WikiDiscussions master Synced 2w ago

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

Crcms Elasticsearch
===================

[](#crcms-elasticsearch)

[![Latest Stable Version](https://camo.githubusercontent.com/dacfd09927af9d0723052c34ba3cf1f9f14b4c7ab5ecd18436b831c5296e9a95/68747470733a2f2f706f7365722e707567782e6f72672f6372636d732f656c61737469637365617263682f762f737461626c65)](https://packagist.org/packages/crcms/elasticsearch)[![License](https://camo.githubusercontent.com/b85e0c2659808191402fd5314d7e676302fd48cd5d7467318bbfaed7103b5c72/68747470733a2f2f706f7365722e707567782e6f72672f6372636d732f656c61737469637365617263682f6c6963656e7365)](https://packagist.org/packages/crcms/elasticsearch)[![StyleCI](https://camo.githubusercontent.com/e03e6512e2afb1c733a5740ef96471e074333b15de5701fa7c3101f1d99eb08a/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3130303932373736332f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/100927763)

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

[](#version-matrix)

Elasticsearch Versioncrcms/elasticsearch Branch&gt;= 7.0master(beta unstable)&gt;= 6.01.\*&gt;= 5.0, &lt; 6.00.\*Install
-------

[](#install)

You can install the package via composer:

```
composer require crcms/elasticsearch

```

> Please install if you want to use the latest version `dev-master`

Use
---

[](#use)

### Non-Laravel framework

[](#non-laravel-framework)

```
// select config path
$config = require 'search.php';
$builder = Factory::builder($config);
```

### Laravel

[](#laravel)

Modify `config / app.php` If the version is less &lt;= 5.5

```
'providers' => [
    CrCms\ElasticSearch\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="CrCms\ElasticSearch\LaravelServiceProvider"

```

Quickstart
----------

[](#quickstart)

### Create

[](#create)

```
$builder->index('index')->type('type')->create([
    'key' => 'value'
]);

// return a collection
$builder->index('index')->type('type')->createCollection([
    'key' => 'value'
]);
```

### Update

[](#update)

```
$builder->index('index')->type('type')->update([
    'key' => 'value1'
]);
```

### Delete

[](#delete)

```
$builder->index('index')->type('type')->delete($result->_id);
```

### Select

[](#select)

```
$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 (Query $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 whereNotBetween($field, array $values): self
```

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

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

```
public function whereNotExists($field, $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()
```

> If you want to expand more, you can use this method, call

Other
-----

[](#other)

For more examples, please see test cases

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~198 days

Total

5

Last Release

2386d ago

Major Versions

0.0.2 → 1.0.02018-03-28

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6357263?v=4)[simon](/maintainers/hiword)[@hiword](https://github.com/hiword)

---

Top Contributors

[![filefox](https://avatars.githubusercontent.com/u/13112043?v=4)](https://github.com/filefox "filefox (2 commits)")[![mowangjuanzi](https://avatars.githubusercontent.com/u/13846040?v=4)](https://github.com/mowangjuanzi "mowangjuanzi (1 commits)")

---

Tags

elasticsearchlaravelormphpquerysqlphplaravelelasticsearchormsql

### Embed Badge

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

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

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.1M11.2k](/packages/illuminate-database)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.4M2](/packages/glushkovds-phpclickhouse-laravel)[basemkhirat/elasticsearch

Laravel, Lumen and Native php elasticseach query builder to build complex queries using an elegant syntax

398313.5k](/packages/basemkhirat-elasticsearch)[matchory/elasticsearch

The missing elasticsearch ORM for Laravel!

3061.7k](/packages/matchory-elasticsearch)[itpathsolutions/dbstan

Database Standardization and Analysis Tool for Laravel

442.1k](/packages/itpathsolutions-dbstan)[calebdw/laravel-sql-entities

Manage SQL entities in Laravel with ease.

311.5k](/packages/calebdw-laravel-sql-entities)

PHPackages © 2026

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