用途:通用的查询条件
依赖类:\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内置的查询表达式 | 可以直接使用 |