- Elasticsearch 教程
- Elasticsearch - 主页
- Elasticsearch - 基本概念
- Elasticsearch - 安装
- Elasticsearch - 填充
- 版本之间的迁移
- Elasticsearch - API 约定
- Elasticsearch - 文档 API
- Elasticsearch - 搜索 API
- Elasticsearch - 聚合
- Elasticsearch - 索引 API
- Elasticsearch - CAT API
- Elasticsearch - 集群 API
- Elasticsearch - 查询 DSL
- Elasticsearch - 映射
- Elasticsearch - 分析
- Elasticsearch - 模块
- Elasticsearch - 索引模块
- Elasticsearch - 摄取节点
- Elasticsearch - 管理索引生命周期
- Elasticsearch - SQL 访问
- Elasticsearch - 监控
- Elasticsearch - 汇总数据
- Elasticsearch - 冻结索引
- Elasticsearch - 测试
- Elasticsearch - Kibana 仪表板
- Elasticsearch - 按字段过滤
- Elasticsearch - 数据表
- Elasticsearch - 区域地图
- Elasticsearch - 饼图
- Elasticsearch - 面积图和条形图
- Elasticsearch - 时间序列
- Elasticsearch - 标签云
- Elasticsearch - 热图
- Elasticsearch - 画布
- Elasticsearch - 日志 UI
- Elasticsearch 有用资源
- Elasticsearch - 快速指南
- Elasticsearch - 有用的资源
- Elasticsearch - 讨论
Elasticsearch - SQL 访问
它是一个允许对 Elasticsearch 实时执行类似 SQL 查询的组件。您可以将 Elasticsearch SQL 视为一种转换器,它可以理解 SQL 和 Elasticsearch,并可以利用 Elasticsearch 功能轻松地实时大规模读取和处理数据。
Elasticsearch SQL 的优点
它具有本机集成- 每个查询都根据底层存储对相关节点有效执行。
无外部部件- 不需要额外的硬件、进程、运行时或库来查询 Elasticsearch。
轻量级且高效- 它包含并公开 SQL 以允许实时进行适当的全文搜索。
例子
PUT /schoollist/_bulk?refresh {"index":{"_id": "CBSE"}} {"name": "GleanDale", "Address": "JR. Court Lane", "start_date": "2011-06-02", "student_count": 561} {"index":{"_id": "ICSE"}} {"name": "Top-Notch", "Address": "Gachibowli Main Road", "start_date": "1989- 05-26", "student_count": 482} {"index":{"_id": "State Board"}} {"name": "Sunshine", "Address": "Main Street", "start_date": "1965-06-01", "student_count": 604}
运行上面的代码,我们得到如下所示的响应 -
{ "took" : 277, "errors" : false, "items" : [ { "index" : { "_index" : "schoollist", "_type" : "_doc", "_id" : "CBSE", "_version" : 1, "result" : "created", "forced_refresh" : true, "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 0, "_primary_term" : 1, "status" : 201 } }, { "index" : { "_index" : "schoollist", "_type" : "_doc", "_id" : "ICSE", "_version" : 1, "result" : "created", "forced_refresh" : true, "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 1, "_primary_term" : 1, "status" : 201 } }, { "index" : { "_index" : "schoollist", "_type" : "_doc", "_id" : "State Board", "_version" : 1, "result" : "created", "forced_refresh" : true, "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 2, "_primary_term" : 1, "status" : 201 } } ] }
SQL查询
以下示例显示了我们如何构建 SQL 查询 -
POST /_sql?format=txt { "query": "SELECT * FROM schoollist WHERE start_date < '2000-01-01'" }
运行上面的代码,我们得到如下所示的响应 -
Address | name | start_date | student_count --------------------+---------------+------------------------+--------------- Gachibowli Main Road|Top-Notch |1989-05-26T00:00:00.000Z|482 Main Street |Sunshine |1965-06-01T00:00:00.000Z|604
注意- 通过更改上面的 SQL 查询,您可以获得不同的结果集。