https://www.elastic.co/guide/en/elasticsearch/reference/7.4/xpack-sql.html
https://www.elastic.co/guide/en/elasticsearch/reference/7.4/sql-translate.html
curl -XPOST "域名/_sql/translate" -H 'Content-Type: application/json' -d'{
"query": "select * from my_index"
}'
curl -XPOST "域名/_sql?format=json" -H 'Content-Type: application/json' -d'{
"query": "select * from my_index"
}'
其中,format 可以是 txt、json 等,见:返回值类型
https://www.elastic.co/guide/en/elasticsearch/reference/7.4/sql-limitations.html#large-parsing-trees
- 只支持
select
- 大的查询可能会抛出
ParsingExpection
- 对于 Nested 类型的字段:
- 只能使用子字段,不能使用该 Nested 字段:
[nested_field_name].[sub_field_name]
- 一个查询中不能包含多个 Nested 字段
- 不支持分页查询
- 只能使用子字段,不能使用该 Nested 字段:
keyword
字段不支持normalizer
- 不支持数组类型的字段(一个字段包含多个值的字段)
- 聚合查询时:
- 只支持对前 512 个文档进行排序
- 聚合函数 MIN、MAX 不能用在子查询中
- 理论上只支持对聚合字段进行排序
- 对于子查询:
- 仅支持有限的简单子查询
- 不支持子查询中包含:group by、having
- 不支持在 having 时使用 FIRST、LAST 函数
- SQL column 必须包含在 _source 中,否则查询不出来(这些类型除外 keyword、date、scaled_float、geo_point、geo_shape)