Elasticsearch-SQL 不念不忘少年蓝@ 2022-07-16 13:44 114阅读 0赞 Elasticsearch-SQL 安装 https://github.com/NLPchina/elasticsearch-sql 一、基本用法 Visit The elasticsearch-sql web front end: http://localhost:9200/_plugin/sql/ Simple query http://localhost:9200/_sql?sql=select * from indexName limit 10 Explain SQL to elasticsearch query DSL http://localhost:9200/_sql/_explain?sql=select * from indexName limit 10 二、sql的用法 --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' 三、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
还没有评论,来说两句吧...