
- 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 - Ingest 節點
- Elasticsearch - 管理索引生命週期
- Elasticsearch - SQL訪問
- Elasticsearch - 監控
- Elasticsearch - 資料彙總
- Elasticsearch - 凍結索引
- Elasticsearch - 測試
- Elasticsearch - Kibana 儀表盤
- Elasticsearch - 按欄位過濾
- Elasticsearch - 資料表
- Elasticsearch - 地區地圖
- Elasticsearch - 餅圖
- Elasticsearch - 面積圖和條形圖
- Elasticsearch - 時間序列
- Elasticsearch - 標籤雲
- Elasticsearch - 熱力圖
- Elasticsearch - Canvas
- 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 查詢,您可以獲得不同的結果集。
廣告