ElasticSearch--------------------->elasticsearch Clients--------------------->java REST Client API

Source: Internet
Author: User



Elasticsearch-->java REST Client API Overview:

Elasticsearch provides the rest web API, so developers can call Elasticsearch in their own restful web

For a detailed description of the Java Rest client API, see the official Documentation:java Rest Client API

You can call Elasticsearch directly using curl:

basic Syntax Format: RESTful API with JSON over HTTP

Use example:

For example, to calculate the number of files in a cluster, we can use this

curl-xget ' http://localhost:9200/_count?pretty '-d ' {"Query": {"Match_all": {}}} ' /span>

Elasticsearch returns an HTTP status code (for example:200 OK ') and (in addition to ' HEAD ' request) a JSON-formatted return value. The previous ' Curl  request will return a JSON body like the following:


{"Count": 0, "_shards": { "Total": 5, "successful": 5, "failed": 0}}

did not see the HTTP header information in the returned results because we did not requirecurl" shows them. To see the header information, you need to combine '-I  parameters to use  curl  command:


curl-i-xget ' Http://localhost:9200/_count?pretty '-d '

  {"Query": {"Match_ All ": {}} '  



ElasticSearch--------------------->elasticsearch clients--------------------->java REST Client API




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.