Elasticsearch Curl Command

Source: Internet
Author: User
Tags kibana

Background boot Elasticsearch
Elasticsearch-2.2.0/bin/elasticsearch-d
Launch Kibana (easy for web-side viewing)
Kibana-4.4.1-linux-x64/bin/kibana


Curl Command
– Simple to think of as a tool to access URLs at the command line
–curl is an open source file Transfer tool that uses URL syntax to work in the command line mode, using
Curl makes it easy to implement common get/post requests.
–curl
–-x how to specify HTTP requests
–head GET POST PUT DELETE
–-d specifying the data to transfer

To create an index library:
Curl-xpost HTTP://LOCALHOST:9200/BJSXT
The index library name must be all lowercase, cannot begin with an underscore, and cannot contain commas

To create an index:
Curl-xpost HTTP://LOCALHOST:9200/BJSXT/EMPLOYEE/1-D
‘{
"First_Name": "John",
"Last_Name": "Smith",
"Age": 25,
"About": "I love to go rock climbing",
"Interests": ["Sports", "music"]
}‘

If you want to make sure that we are creating new content, use the op_type=create, _create
Curl-xput http://localhost:9200/bjsxt/emp/2?op_type=create-d ' {"name": "Zs", "Age": 25} '
Curl-xput http://localhost:9200/bjsxt/emp/2/_create-d ' {"name": "Laoxiao", "Age": 25} '
Back to 201 created/409 Conflict

Query based on employee ID:
Curl-xget Http://localhost:9200/bjsxt/employee/1?pretty
After curl add the-i parameter, you can get the feedback header file
Curl-i ' Http://localhost:9200/bjsxt/employee/1?pretty '
Add the pretty parameter to any query string, ES can get JSON results that are easy to recognize

Get Query Index
Retrieves a portion of a document, showing only the Name,age field
Curl-xget Http://localhost:9200/bjsxt/employee/1?_source=name,age
If you only need data from source
Curl-xget Http://localhost:9200/bjsxt/employee/1/_source
Query all
Curl-xget Http://localhost:9200/bjsxt/employee/_search
Query based on criteria
Curl-xget Http://localhost:9200/bjsxt/employee/_search?q=last_name:Smith

Get multiple documents using the Mget API
Curl-xget http://localhost:9200/_mget?pretty-d ' {
"Docs": [{
"_index": "BJSXT",
"_type": "EMP",
"_id": 2,
"_source": "Name"
},{
"_index": "Website",
"_type": "Blog",
"_ID": 2
}]}‘

If you only want to check if the document exists, you can use head instead of the Get method, which will return only the HTTP header file:
Curl-i-xhead HTTP://LOCALHOST:9200/BJSXT/EMPLOYEE/1

Version control for Elasticsearch
First get the document that needs to be modified, get the version (_version) number
Curl-xget HTTP://LOCALHOST:9200/BJSXT/EMPLOYEE/1
The version number is passed when the update operation is performed
Curl-xput http://localhost:9200/bjsxt/employee/1?version=2-d ' {"name": "Zs", "Age": 25} '
Coverage
Curl-xpost http://localhost:9200/bjsxt/employee/1/_update?version=3-d ' {"Doc": {"City": "Beijing", "Car": "BMW"}} '
(Partial update)

Elasticsearch Curl Command

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.