All statements are no default user name and password, if you do a cluster es safety certification, please in every crul followed by -u username: password
E.g:
curl -u admin:123456 -XGET "http://172.0.0.52:9200/_cat"
1 cluster support options
curl -XGET "http://172.0.0.52:9200/_cat"
2 View node information
curl -XGET "http://172.0.0.52:9200/_cat/nodes?v"
3 View master node information
curl -XGET "http://172.0.0.52:9200/_cat/master?v"
4 View All Hot thread on the node
curl -XGET "http://172.0.0.52:9200/_nodes/hot_threads"
5 Access to the problem of fragmentation or index
curl -XGET "http://172.0.0.52:9200/_cluster/allocation/explain?pretty"
6 Check the thread pool settings
curl -XGET "http://172.0.0.52:9200/_nodes/thread_pool/"
7 All statistical information
curl -XGET "http://172.0.0.52:9200/_cluster/stats?human&pretty"
8 View cluster status
curl -XGET "http://172.0.0.52:9200/_cluster/health?pretty"
ES 9 View information
curl -XGET "http://172.0.0.52:9200/"
10 access to information for all indexes
curl -XGET "http://172.0.0.52:9200/_cat/indices?v&pretty"
curl -XGET "http://172.0.0.52:9200/_cat/nodes?v"
curl -XGET "http://172.0.0.52:9200/_cat/segments?v&h=shard,segment,size,size.memory"
11 Get all the number of documents
curl -XGET "http://172.0.0.52:9200/_count?pretty" -H 'Content-Type: application/json' -d'
{ "query": { "match_all": {} } }'
12 View cluster health status
- green: all functions are intact;
- yellow: all data is available, but some copies have not yet been allocated;
- Some data representative of red has been unavailable for some reason.
Note that , although a cluster is a red state, it can still provide some of the services (for example, it will continue searching from the slice data available in), but after the loss of part of the data, you need to fix as soon as possible.
curl -XGET "http://172.0.0.52:9200/_cat/health?v"
13 Creating an index
- test_one index name
- pretty good parameter indicates output JSON response (if present)
curl -XPUT "http://172.0.0.52:9200/test_one?pretty"
14 View index list
curl -XGET "http://172.0.0.52:9200/_cat/indices?v"
curl -XGET "http://172.0.0.52:9200/test_one"
15 Delete Index
Delete the index name.
curl -XDELETE "http://172.0.0.52:9200/test_one?pretty"
- You can delete several indexes (separated by commas)
- Delete all index _all or wildcard *
16 Creating Documents
PUT use to create a document, you need to specify the id.
- Index index: test_one
- Type type: test_type
- _id:1
curl -XPUT "http://172.0.0.52:9200/test_one/test_type/1?pretty" -H 'Content-Type: application/json' -d'
{"name": "ghl", "age": 24, "sex": "male"}'
Using POST to create a document, you can not specify the id (randomly generated id is not specified)
curl -XPOST "http://172.0.0.52:9200/test_one/test_type?pretty" -H 'Content-Type: application/json' -d'
{"name": "Jack"}'
17 view documents
curl -XGET "http://172.0.0.52:9200/test_one/test_type/1?pretty"
18 Replace Document
Use PUT and specify id, es replaces the original document with the new document.
curl -XPUT "http://172.0.0.52:9200/test_one/test_type/1?pretty" -H 'Content-Type: application/json' -d'
{"name": "Jack"}'
19 Update Documentation
curl -XPOST "http://172.0.0.52:9200/test_one/test_type/1/_update?pretty" -H 'Content-Type: application/json' -d'
{"doc":{"name": "Lucy"}}'
20 Delete Document
curl -XDELETE "http://172.0.0.52:9200/test_one/test_type/1?pretty"
CRUD index has a similar format in:
- REST-style syntax predicate
- Node ip
- Node port number, default 9200
- Index Name
- Index Type
- Operation target ID number
curl -XGET "http://172.0.0.52:9200/<Index>/<Type>/<ID>"
21 determines whether there is an index
curl -XHEAD "http://172.0.0.52:9200/test_one"
View 22 Index Template
curl -XGET "http://172.0.0.52:9200/_template/template_1"
curl -XGET "http://172.0.0.52:9200/_template/temp*"
curl -XGET "http://172.0.0.52:9200/_template/template_1,template_2" curl -XGET "http://172.0.0.52:9200/_template"
23 Remove Templates
curl -XDELETE "http://172.0.0.52:9200/_template/template_1"
24 open / close index
curl -XPOST "http://172.0.0.52:9200/test_one/_close"
curl -XPOST "http://172.0.0.52:9200/test_one/_open"
curl -XGET "http://172.0.0.52:9200/_cat/indices?v"
25 view the index status
curl -XGET "http://172.0.0.52:9200/_stats"
curl -XGET "http://172.0.0.52:9200/logstash-nginx-access-2019.08.07,test_one/_stats"
26 View index segment information
curl -XGET "http://172.0.0.52:9200/test_one/_segments"
curl -XGET "http://172.0.0.52:9200/logstash-nginx-access-2019.08.07,test_one/_segments"
curl -XGET "http://172.0.0.52:9200/_segments"