composer require flc/laravel-elasticsearch
v2.0.0 版本开始仅支持 Elasticsearch 7.x 版本,扩展依赖 elasticsearch/elasticsearch ^7.0 ,如使用 Elasticsearch 6.x 请使用 v1.1.0 版本。
Elasticsearch Version | Elasticsearch-PHP Branch |
---|---|
>= 7.x | >= 7.x |
<?php
use Elasticsearch;
Elasticsearch::index('users')
->select('id', 'username', 'password', 'created_at', 'updated_at', 'status', 'deleted')
->whereTerm('status', 1)
->orWhereIn('deleted', [1, 2])
->whereNotExists('area')
->where(['status' => 1, 'closed' => 0])
->where(function ($query) {
$query->where('status', '=', 1)
->where('closed', 1)
->where('username', 'like', '张三');
->where('username', 'match', '李四');
})
->orderBy('id', 'desc')
->take(2)
->paginate(10);
// ->get();
// ->search();
- MIT
- Anti 996