Elasticsearch6.3.0學習筆記(一)

安裝

參考官方文檔提供的安裝教程:https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html

啓動

在win7上用msi文件進行的安裝,進入安裝目錄中的bin目錄執行elasticsearch.exe

使用REST API操作Elasticsearch

使用postman來調用Elasticsearch的REST API接口進行交互

創建索引

PUT   localhost:9200/索引名稱/類型名稱/ID

個人理解爲ES中可以存在多個索引

索引中可以存在多種類型

類型中可以存放不同ID的數據

body中以json格式寫入要綁定該ID的數據

創建成功後的結果:


更多詳情請參考:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html

獲取索引

GET    localhost:9200/查詢索引名稱/查詢類型名稱/查詢ID

查詢結果:


參考:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html

更新索引

腳本更新

POST    localhost:9200/movies/movie/1/_update


結果爲movies索引下的movie類型下ID爲1的year字段增加1000:


部分文檔更新

POST    localhost:9200/movies/movie/1/_update


更新title字段

參考:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html

刪除索引

DELETE     localhost:9200/movies/movie/1

參考:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html

查詢索引

POST    localhost:9200/[索引名稱]/[類型名稱]/_search

[ ]表示可選項



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章