ElasticSearch SQL 操作符
- 相等 (=)
- 安全的空值相等 (<=>)
- 不等 (<> 或 !=)
- 比较(<, <=, >, >=)
- BETWEEN
- IS NULL/IS NOT NULL
- IN (<value1>, <value2>, ...)
- AND OR
- NOT
- 加 (+)、 减(infix -)、 取反(unary -)、 乘(*)、 除(/)、 取模运算(%)
对人工智能感兴趣的同学,可以点击以下链接:
1、相等 (=)
select message from rep where response = 404 limit 2;
2、安全的空值相等 (<=>)
SELECT 'hello' <=> null AS "equals";
equals
---------------
false
SELECT null <=> null AS "equals";
equals
---------------
true
3、不等 (<> 或 !=)
select message from rep where clientip <> '192.168.150.140' limit 2;
4、比较(<, <=, >, >=)
SELECT last_name l FROM "test_emp" WHERE emp_no < 10003 ORDER BY emp_no LIMIT 5;
5、BETWEEN
SELECT last_name l FROM "test_emp" WHERE emp_no BETWEEN 9990 AND 10003 ORDER BY emp_no;
6、IS NULL/IS NOT NULL
SELECT last_name l FROM "test_emp" WHERE emp_no IS NOT NULL AND gender IS NULL;
7、IN
select message from rep where verb in ('GET','POST') limit 2;
8、AND、OR
select message from rep where (verb = 'GET' or verb ='POST' ) and clientip = '192.168.150.140' and response = 404 limit 2;
9、NOT
select message from rep where not response = 404 limit 2;
10、+ - * / %
select 1+2*3/6+10%2 as result;