ElasticSearch的API介紹


              ElasticSearch的API介紹

                               作者:尹正傑

版權聲明:原創作品,謝絕轉載!否則將追究法律責任。

 

 

一.ES是基於Restful風格

1>ES是基於Restful風格

Elasticsearch有四類API:

    第一:檢查集群,節點,索引等健康與否,以及獲取其相應狀態;

    第二:管理集群,節點,索引及元數據;

    第三:執行CRUD(增刪查改)操作;

    第四:執行高級操作,例如:paging,filtering等

  ES訪問接口:9200/TCP,它是HTTP請求,我們可以通過curl命令訪問,格式為:“curl -x<VERB> ‘<PROTOCOL>://HOST:PORT/<PATH>?<QUERY_STRING> -d '<BODY>' ”

    VERB        :GET,PUT,DELETE等;

    PROTOCOL     :http,https

    QUERY_STRING     :查詢參數,例如?pretty表示用易讀的JSON格式輸出。

    BODY        :請求的主題

    案例展示:      
        查看ES集群的工作狀態:
            curl -X GET 'http://node101.yinzhengjie.org.cn:9200/_cat'                #查看ES可以查看的方法
            curl -X GET 'http://node101.yinzhengjie.org.cn:9200/_cat/nodes'           #查看各個node節點信息,不顯示頭部信息
            curl -X GET 'http://node101.yinzhengjie.org.cn:9200/_cat/nodes?v'        #查看各個node節點信息,顯示頭部信息    
            curl -X GET 'http://node101.yinzhengjie.org.cn:9200/_cat/master?v'        #顯示主節點信息,顯示頭部信息    
            curl -X GET 'http://node101.yinzhengjie.org.cn:9200/_cat/health?v'        #查看集群的節點狀態

2>.ES的查詢網站

  官方API文檔:https://www.elastic.co/guide/en/elasticsearch/reference/6.5/index.html

 

  

 

二.ES的cat的API使用詳解(主要用於查看某個節點的信息)

1>.ES的cat文檔API的官方文檔

  詳情請參考:https://www.elastic.co/guide/en/elasticsearch/reference/6.5/cat.html

2>.查看cat接口的子API([root@node101 ~]# curl -XGET http://node101.yinzhengjie.org.cn:9200/_cat)

3>.查看當前ES的節點信息([root@node101 ~]# curl -XGET http://node101.yinzhengjie.org.cn:9200/_cat/nodes)

 

 

4>.查看集群的健康狀態([root@node101 ~]# curl -XGET http://node101.yinzhengjie.org.cn:9200/_cat/health?v)

 

 

 

三.ES的Cluster的API使用詳解(主要用於查看集群狀態的)

1>.ES的cluster文檔API的官方文檔

  詳情請參考:https://www.elastic.co/guide/en/elasticsearch/reference/6.5/cluster.html

2>.查看集群的監控狀態([root@node101 ~]# curl -XGET http://node101.yinzhengjie.org.cn:9200/_cluster/health?pretty)

 

3>.查看集群的版本號([root@node101 ~]# curl -XGET 'http://node101.yinzhengjie.org.cn:9200/_cluster/state/version?pretty')

 

 

4>.查看ES的_cluster接口的state狀態([root@node101 ~]# curl -XGET 'http://node101.yinzhengjie.org.cn:9200/_cluster/state/nodes?pretty')

  參考文檔:https://www.elastic.co/guide/en/elasticsearch/reference/6.5/cluster-state.html

 

5>.查看ES的cluster API說明

   官方文檔:https://www.elastic.co/guide/en/elasticsearch/reference/6.5/cluster.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM