iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 5
2
Elastic Stack on Cloud

Elastic 戰台股系列 第 5

[Day05] 盤後資料上 ES Cloud - 以 Postman 為例

雲南黃悶雞佐料:醬油(最好是豆油伯,天然甜),白胡叔粉
忽然發覺功夫菜這樣寫,也是很麻煩……
誤上賊船

Day04 時踩了ES Cloud 的 API Key 小坑,今天就來實際的用 HTTP Client 打 API 操作 Elasticsearch。

組合 URL

Day04 時介紹過 RESTFul API 的 URL format,以建立新的 Index 為例:

http://<HOST>/{index_name}

我們可以在 ES Cloud 的 Deployment 頁面找到 Host:
https://ithelp.ithome.com.tw/upload/images/20200914/20129624iNaCveSiuM.png

透過 Postman 建立 Index

嘗試用 Postman 建一個命名為 history-prices-postman 的 Index。打開 Postman,新增一個新的 Request,選擇 PUT metohd,填上組合出來的 URL,並在 Header 中新增 Autorization 和 Content-Type,如下圖:
https://ithelp.ithome.com.tw/upload/images/20200914/20129624YK7QUkdSMB.png
其中 Authorization 可以用 Api Key 或是 Basic authentication (詳見 Day04)。然後新增 Body,如下圖:
https://ithelp.ithome.com.tw/upload/images/20200914/20129624W4Lts22jMI.png
按下 Send,即可收到成功的 Response:
https://ithelp.ithome.com.tw/upload/images/20200914/20129624e1k4B9zmUX.png

Index 一筆盤後資訊

同樣透過 Postman ,來試試 Index 一筆盤後資訊,如下圖。為了方便查找,給該 Document 一個 ID (100)。
https://ithelp.ithome.com.tw/upload/images/20200914/20129624UwUfhU6GMm.png

今天搞定了 HTTP Client 操作 ES 的方式,接下來的問題是如何大量上傳盤後資訊,以及 Document 的 Mapping。這是接下來的任務!


上一篇
[Day04] 盤後資料上 ES Cloud - RESTful API Introduction
下一篇
[Day06] 資料還是要有點規範 - Mapping
系列文
Elastic 戰台股30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言