SELECT fields from indexName WHERE conditions
要查询特定类型的索引,请使用:
SELECT fields from indexName/type WHERE conditions
您还可以一次查询多个类型和索引,如下所示:
SELECT fields from indexName/type1,indexName/type2 WHERE conditions
SQL语句
SQL Select
SQL Delete
SQL Where
SQL Order By
SQL Group By
SQL Limit (默认为200)
条件:
SQL Like
SQL AND & OR
SQL COUNT distinct
SQL In
SQL Between
SQL Aliases
SQL(ES) Date
SQL now()
SQL NOT
基本汇总:
SQL avg()
SQL count()
SQL last()
SQL max()
SQL min()
SQL sum()
SQL字段
字段可以按精确字段名称列出,也可以与包含/排除语法一起使用以与通配符一起使用。
include('d *') - 包括以“d”开头的所有字段
exclude('age') - 包括除“age”之外的所有字段
include('* Name'),exclude('lastName') - 包括以“name”结尾的所有字段,“lastName”除外
Elasticsearch-sql聚合
我们支持几种弹性搜索聚合
min
max
sum
count
avg
stats
percentiles
extended_stats
在数字字段上使用这样的:
SELECT stats(age) FROM account
scripted_metric (read below on how to use)
buckets
术语聚合
使用group by fieldName,您也可以放置多个字段
例子
SELECT COUNT(*) FROM account GROUP BY gender
SELECT COUNT(*) FROM account GROUP BY gender, age
多个聚合
使用group by(fieldName),(fieldName,fieldName)
括号中的每个字段都有自己的聚合
括号中的每个字段列表都是自己的子聚合聚合
例子
SELECT * FROM account GROUP BY (gender),(age)
SELECT * FROM account GROUP BY (gender, state),(age)
SELECT * FROM account GROUP BY (gender, state, age),(state),(age)
范围聚合
将fieldName后跟您的范围
例如,如果您想要范围:年龄与组20-25,25-30,30-35,35-40
SELECT COUNT(age) FROM bank GROUP BY range(age, 20,25,30,35,40)
日期直方图聚合
put fieldName和interval
别名是可选的
例
SELECT online FROM online GROUP BY date_histogram(field='insert_time','interval'='1d','alias'='yourAlias')
日期范围聚合
将您的fieldName和特殊间隔放在格式中
别名是可选的
SELECT online FROM online GROUP BY date_range('alias'='yourAlias',field='insert_tim
SELECT * FROM account where nickname is not missing
SELECT * FROM account where nickname is missing
SELECT * FROM account where name = IN_TERMS(hattie,alis)
SELECT * FROM account where age = TERM(4)
SELECT * FROM account where _id = IDS_QUERY(account,1,2,5)
SELECT stats(age) FROM account
SELECT extended_stats(age) FROM account
SELECT percentiles(age) FROM accounts
SELECT address FROM bank where q=query('address:880 Holmes Lane')
SELECT * FROM dog where dog_name = REGEXP_QUERY('sn.*', 'INTERSECTION|COMPLEMENT|EMPTY', 10000)