GET _sql { "cursor":"w7ysAwFzQERYRjFaWEo1UVc1a1JtVjBZMmdCQUFBQUFBSHp3OTRXU2pkdFRtMXpkMGRSTVcxaE1IRlljV3BLT0haMmR3PT3/////DwEBZgRuYW1lAQR0ZXh0AVoAAAABAQ==", "fetch_size":2 }
占位符的使用
1 2 3 4 5
POST /_sql?format=txt { "query": "SELECT YEAR(release_date) AS year FROM library WHERE page_count > ? AND author = ? GROUP BY year HAVING COUNT(*) > ?", "params": [300, "Frank Herbert", 0] }
使用DESCRIBE语句查看表(ES中为索引)中有哪些字段
1 2 3 4
POST /_sql?format=txt { "query": "DESCRIBE \"index-user-2020.09.08\"" }
使用SHOW TABLES查看所有的表(ES中为索引)
1 2 3 4
POST /_sql?format=txt { "query": "SHOW TABLES" }
查询支持的函数
1 2 3 4 5 6 7 8
POST /_sql?format=txt { "query": "SHOW FUNCTIONS" } POST /_sql?format=txt { "query": "SHOW FUNCTIONS LIKE '%DATE%'" }
全文搜索函数Match()(全文搜索函数是ES中特有的)
1 2 3 4 5
# 使用MATCH函数查询tag中包含spxm-mas的记录 POST /_sql?format=txt { "query":"select id,name,pwd,sex from \"index-user-2020.09.08\" where MATCH(name,'admin') limit 10" }
全文搜索函数QUERY()
1 2 3 4 5
# 使用QUERY函数查询tag中包含spxm-mas的记录 POST /_sql?format=txt { "query":"select id,name,pwd,sex from \"index-user-2020.09.08\" where QUERY('name:admin') limit 10" }