Install and use curl to interact with ES in windows environment

1. Download and install

Go to the official website to download the corresponding version of the package, after decompression, open CMD and switch to the corresponding directory (my directory, E:\file\I386) to run the CURL.exe file,

If you copy the CURL.exe file to the C:\Windows\System32 directory, you do not need to switch directories, and you can run the curl command directly.

2. Request Elasticsearch

The premise is that es has been installed and started.

Here it means that es can be accessed normally.

So how to initiate a request with a json string requestBody?

For example: we want to index a document

Then you need to enter the following command:

curl -H "Content-Type:application/json" -H "Accept:application/json" -X PUT  http://localhost:9200/megacorp/employee/1?pretty -d "{\"first_name\":\"John\",\"last_name\":\"Smith\",\"age\" :25,\"about\" :\"I love to go rock climbing\",\"interests\": [ \"sports\", \"music\" ]}"

 

Note: The request header needs to be added, and the " in parentheses needs to be escaped.

Query all documents to see that they have been added successfully.

Reference documentation: The Definitive Guide to Elasticsearch

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325001746&siteId=291194637