数据库 - Model 前置说明
官方开源项目 抓取代理IP

参数说明

用途:通用的查询条件
依赖类:\x\Elasticsearch
方法名:where()

参数:

  • string|array $field

    • 功能:查询的字段或者查询规则(二维数组)。
    • 默认值:无
  • string $operator

    • 功能:查询表达式。
    • 默认值null
  • mixed $value

    • 功能:查询内容。
    • 默认值false
  • string $type

    • 功能:查询模式。
    • 默认值must

返回值:this

使用示例:

$Elasticsearch = new \x\Elasticsearch();
// 场景:字符串
$Elasticsearch->table('shop')->where('title', 'match', '骑士队');
// 场景:数组
$where = [
    ['title', '=', '骑士队', 'must'],
    ['title', '=', '利夫兰', 'filter'],
    ['age', '>=', 18],
    ['age', '<=', 28],
    ['title', 'terms', ['测试', 'H']]
];
$Elasticsearch->table('shop')->where($where);

查询表达式的转换规则

组件内部会把查询表示的字符串转换成Elasticsearch内置的字符串规则,具体转换逻辑如下:

组件 Elasticsearch
= match
>gt range
<lt range
>=gte range
<=lte range
ES内置的查询表达式 可以直接使用

SW-X

企业级 - 高性能 PHP 框架

最后更新:2年前 . 作者-小黄牛

本篇目录