Elasticsearch--------------------->Elasticsearch Clients--------------------->Java REST Client API

來源:互聯網
上載者:User

標籤:web api   div   mat   bsp   .com   UI   images   文檔   ges   

Elasticsearch——>Java REST Client API概述:
  • elasticsearch提供了REST WEB API,所以開發人員可以在自己的restful web中調用elasticsearch
  • 關於Java REST Client API的詳細敘述,參見官方documentation:Java REST Client API
可以直接使用curl來調用elasticsearch:
  • 基本文法格式:RESTful API with JSON over HTTP
  • 使用樣本:
    • 例如,計算叢集中文檔的數量,我們可以用這個
    • curl -XGET ‘http://localhost:9200/_count?pretty‘ -d ‘{    "query": {        "match_all": {}    }}‘

      Elasticsearch 返回一個 HTTP 狀態代碼(例如:200 OK`)和(除`HEAD`請求)一個 JSON 格式的傳回值。前面的 `curl 請求將返回一個像下面一樣的 JSON 體:

      {    "count" : 0,    "_shards" : {        "total" : 5,        "successful" : 5,        "failed" : 0    }}

      在返回結果中沒有看到 HTTP 頭資訊是因為我們沒有要求curl`顯示它們。想要看到頭資訊,需要結合 `-i 參數來使用 curl 命令:

      curl -i -XGET ‘http://localhost:9200/_count?pretty‘ -d ‘
      {    "query": {        "match_all": {}    }}‘
       

Elasticsearch--------------------->Elasticsearch Clients--------------------->Java REST Client API

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.