插件名:Elasticsearch-SQL
下载地址:https://github.com/NLPchina/elasticsearch-sql
注意:安装好后记得重启es
一些示例:
Query
SELECT * FROM bank WHERE age >30 AND gender = 'm'
Aggregation
select COUNT(*),SUM(age),MIN(age) as m, MAX(age),AVG(age)
FROM bank GROUP BY gender ORDER BY SUM(age), m DESC
Delete
DELETE FROM bank WHERE age >30 AND gender = 'm'
Beyond sql
Search
SELECT address FROM bank WHERE address = matchQuery('880 Holmes Lane') ORDER BY _score DESC LIMIT 3
Aggregations
range age group 20-25,25-30,30-35,35-40
SELECT COUNT(age) FROM bank GROUP BY range(age, 20,25,30,35,40)
range date group by day
SELECT online FROM online GROUP BY date_histogram(field='insert_time','interval'='1d')
range date group by your config
SELECT online FROM online GROUP BY date_range(field='insert_time','format'='yyyy-MM-dd' ,'2014-08-18','2014-08-17','now-8d','now-7d','now-6d','now')
ES Geographic
SELECT * FROM locations WHERE GEO_BOUNDING_BOX(fieldname,100.0,1.0,101,0.0)
Select type
SELECT * FROM indexName/type