In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the commonly used curl commands in ElasticSearch, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
1. Curl-XGET 'http://10.240.0.8:9200/_cat' options supported by the cluster
Cymbal
two。 View node information curl-XGET 'http://10.240.0.8:9200/_cat/nodes?v'
Cymbal
3. View master node information curl-XGET 'http://10.240.0.8:9200/_cat/master?v'
Cymbal
4. Check the health status of the cluster curl-XGET 'http://10.240.0.8:9200/_cat/health?v'
Cymbal
You can see that our cluster is called "es-test" and the status is green.
Whenever we ask for the health status of the cluster, we get three: green, yellow, and red.
Green means that all functions are intact.
Yellow means that all data is available, but some copies have not yet been allocated
Red represents some data that is no longer available for some reason. Note that although a cluster is in red state, it can still provide some services (for example, it will continue to search through available slice data), but after you lose some of the data, you need to fix it as fast as you can.
5. Create an index # test_one index name # pretty parameter indicates a well-formatted JSON response (if present) curl-XPUT 'http://10.240.0.7:9200/test_one?pretty'
Cymbal
6. View the index list curl-XGET 'http://10.240.0.7:9200/_cat/indices?v'
Cymbal
Test_one is the index you just created
7. Delete index
Delete based on index name
Curl-XDELETE 'http://10.240.0.8:9200/test_3?pretty'
Cymbal
8. Create a document
When inserting a document (dic) into an es, you must specify a type (type)
1. To create a document using PUT, you need to specify the id# index index:test_one# type type:test_type# _ id:1curl-XPUT "http://10.240.0.7:9200/test_one/test_type/1"-d'{" name ":" john "," age ": 28}'
Cymbal
If the error is reported above, you need to access the request header.
Curl-H "Content-Type: application/json"-XPUT "http://10.240.0.7:9200/test_one/test_type/1?pretty"-d'{" name ":" eson "," age ": 35}'
Cymbal
two。 To create a document using POST, you can not specify id (randomly generate id when not specified) curl-H "Content-Type: application/json"-XPOST 'http://10.240.0.7:9200/test_one/test_type?pretty'-d' {"name": "suzhang"}'
Cymbal
9. View the document curl-XGET 'http://10.240.0.7:9200/test_one/test_type/1?pretty'
Cymbal
10. Replace document
When you use PUT and specify id, es replaces the original document with a new document
Curl-H "Content-Type: application/json"-XPUT 'http://10.240.0.7:9200/test_one/test_type/1?pretty'-d' {"name": "su"}'
Cymbal
11. Update the document curl-H "Content-Type: application/json"-XPOST 'http://10.240.0.7:9200/test_one/test_type/2/_update?pretty'-d' {"doc": {"name": "suxxxnxxg"}'
Cymbal
twelve。 Delete document curl-XDELETE 'http://10.240.0.7:9200/test_one/test_type/2?pretty'
After reading the above, do you have any further understanding of the commonly used curl commands in ElasticSearch? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.