Elasticsearch上手——熟悉基本操作

來源:互聯網
上載者:User

Kibana為快速熟悉Elasticsearch的操作提供極大的便利,下面就通過kibana熟悉幾個基本的操作。 建立索引(index)

在Kibana中開啟Dev Tools,會開啟如下圖所示的操作介面:

左側是命令視窗,右側執行的結果。
下面是建立一個名稱為blog_index的索引,包含了兩個type:user和blogpost,

PUT blog_index {  "mappings": {    "user": {       "properties": {         "title":    { "type": "text"  },         "name":     { "type": "text"  },         "age":      { "type": "integer" }        }    },    "blogpost": {       "properties": {         "title":    { "type": "text"  },         "body":     { "type": "text"  },         "user_id":  {          "type":   "keyword"         },        "created":  {          "type":   "date",           "format": "strict_date_optional_time||epoch_millis"        }      }    }  }}

如圖:

右側的結果表示執行成功

下面就可以通過Management->Index Patterns添加index pattern,

點擊Create按鈕儲存。 索引文檔

下面索引一個user文檔,如下:

{   "title": "manager",   "name": "Tom Jerry",   "age": 34}

執行命令為POST blog_index/user,表示向blog_index下添加user類型的文檔。從右側的輸出結果可以看出,添加文檔成功,並且自動分別了一個_id 搜尋

首先通過Kibana的Discover可以看到剛才添加的文檔:

如果通過命令完成搜尋,結果為:

執行的命令為:

GET /blog_index/user/_search{  "query":{    "match": {        "name": "jerry"    }  }}

注意:命令列和參數之間不能有空行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.