hungneox / ramen-elastic-query
Lumen/Laravel 用于与 Elasticsearch 交互的包
dev-master
2018-01-21 18:43 UTC
Requires
- illuminate/console: ^5.5
- illuminate/http: ^5.5
- illuminate/support: v5.5.17
- nordsoftware/lumen-elasticsearch: ^2.3.6
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-09-21 16:38:42 UTC
README
基于 Lumen Elasticsearch 的 Elasticsearch 模拟伪 SQL 查询构建器
安装
运行以下命令通过 Composer 安装此包
composer require hungneox/ramen-elastic-query
将以下行添加到 bootstrap/app.php
$app->register(Neox\Ramen\Elastic\ElasticQueryServiceProvider::class);
用法
简单选择
对象初始化或外观均可
$builder = app(Builder::class); $result = $builder ->use('content') // collection ->from('article') // type ->find('TIYKtQX', '_id', ['id', 'title', 'description']); $result = ES::use('content') ->from('article') ->find('TIYKtQX', '_id', ['id', 'title', 'description']);
常规 where 子句
$result = $builder->select('id', 'description') ->from('recipe') ->where('_id', '=', $id) ->get();
全文匹配
$result = $builder ->use('content') ->select('id', 'title', 'description', 'featured') ->from('article') ->where('title', 'like', 'Auringonkukan') ->orderBy('featured', 'desc') ->get();
删除
ES::use('content')->from('article')->delete($id);
许可证
见 LICENSE。