galexth/elasticsearch-querybuilder
Composer 安装命令:
composer require galexth/elasticsearch-querybuilder
包简介
elasticsearch querybuilder
README 文档
README
Elastica query builder for laravel.
Rules
Each rules have to implement \Galexth\QueryBuilder\Rule interface with pattern() array:
class MyRule implements Rule { public function patterns(): array { return [ [ 'name' => 'location.country', // name of the field in the query (@location.country has ....) 'query_type' => 'terms', // query type (terms, term, match, multi_match, etc...) 'fields' => ['locations.country'], // fields to search in // nested if necessary 'nested' => [ 'path' => 'locations' ], 'type' => 'text', // value type (text, integer, date), text is only supported by now ], // custom handler [ 'name' => 'persona', 'query_type' => 'custom', 'fields' => ['persona_id'], 'type' => 'text', 'callback' => function ($values) { $bool = new BoolQuery(); return $bool->addFilter(new Terms('asd', (array) $values)); } ], // using a regular expressions [ 'name' => 'rank\.(?<sub_field>[\w-_]+)$', 'expression' => true, 'query_type' => 'terms', 'fields' => ['ranks.{sub_field}'], 'type' => 'text', ], ... ]; } }
Query
Use queries like:
$query = '@name is Prof. Johan Schoen and @industry is Network Security Hardware & Software'; $query = '@name is "John" and @industry is \'Medicine\' or (@industry is Oil and @name is Chris) or @name is Jesus'; $query = '@revenue gte 123 and @revenue lt 523'; ...
More examples could be found in tests.
$builder = new Builder(new MyRule); $bool = $builder->build($query); // BoolQuery
galexth/elasticsearch-querybuilder 适用场景与选型建议
galexth/elasticsearch-querybuilder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 232 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 08 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「elasticsearch」 「querybuilder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 galexth/elasticsearch-querybuilder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 galexth/elasticsearch-querybuilder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 galexth/elasticsearch-querybuilder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Parse JSON coming from jQuery QueryBuilder, into database queries.
Lightweight, fast query-builder for PHP based on Laravel Eloquent but with less overhead.
The Query Builder may be used to generate SQL queries in an object orientated fashion.
simple api library.
Doctrine DBAL adapter for Rekapager pagination library
Parse JSON coming from jQuery QueryBuilder, into database queries.
统计信息
- 总下载量: 232
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-11