命令行模式
- 进入命令行
小小操作一下
是不是特别的爽呢?比之前的要简单的太多了啦!
备注:每一个索引就对应着一张表额,但是支持的语法还是比较少的,所以两种都要了解一下
请求模式
- 查询所有表
URL:POST /_xpack/sql
参数:
{
"query": "show tables"
}
结果:
{
"columns": [
{
"name": "name",
"type": "keyword"
},
{
"name": "type",
"type": "keyword"
}
],
"rows": [
[
"alvin",
"BASE TABLE"
],
[
"chzhao",
"BASE TABLE"
],
[
"chzhao-index",
"BASE TABLE"
]
]
}
- 查询年龄大于19,按照年龄排序
URL :POST /_xpack/sql
参数:
{
"query": "select * from alvin where age > 19 order by age desc"
}
结果:
{
"columns": [
{
"name": "address",
"type": "text"
},
{
"name": "age",
"type": "integer"
},
{
"name": "name",
"type": "text"
}
],
"rows": [
[
"河南",
22,
"Lindar"
],
[
"河南",
22,
"Tom"
],
[
"河南",
22,
"Lush"
],
[
"河南",
20,
"Alvin"
],
[
"上海",
20,
"Jack"
],
[
"北京",
20,
"Mosson"
]
]
}
一切就是这么完美