Detailed explanation of operating es commands on Elasticsearch linux

Detailed explanation of operating es commands on Elasticsearch linux

1. Check whether the ES node starts normally

curl http://127.0.0.1:9200

insert image description here

非正常状态:

  1>确保服务是不是正常启动了,端口用的是哪个

  2>防火墙是否关闭或者端口是否开放

  3>你的curl命令是否有问题,curl命令可能导致服务无法访问,可以尝试重启服务后,在外部浏览器访问URL地址即可。不一定非得用curl

2. Query all indexes in es, all existing indexes

curl http://127.0.0.1:9200/_cat/indices?v 

3. Delete the index

curl -XDELETE  http://127.0.0.1:9200/oam_behavior?pretty 

4. Create es index

curl -XPUT http://127.0.0.1:9200/oam_behavior?pretty

5. Query all data of es

curl -XGET http://127.0.0.1:9200/oam_behavior/_search?pretty -k

6. Query the specified ID data

curl -XGET http://127.0.0.1:9200/oam_behavior/oam_log/00-ab7259b3-6860-48cb-b6b1-c8ab77bbb45c?pretty -k

insert image description here

7. Delete the specified ID data

curl -XDELETE http://127.0.0.1:9200/oam_behavior/oam_log/00-ab7259b3-6860-48cb-b6b1-c8ab77bbb45c?pretty -k

8. Query paging data (from refers to the record from which size refers to the number of displayed items)

curl -XPOST  http://127.0.0.1:9200/oam_behavior/_search?pretty -H  'content-Type:application/json'  -d '{"query":{"match_all":{}},"from":10,"size":10}'

9. Add a piece of data

curl -XPUT http://127.0.0.1:9200/oam_behavior/user/2?pretty -H 'content-Type:application/json' -d '{"name":"xxx","age":"23"}'

insert image description here

10. Query by ID

curl http://127.0.0.1:9200/oam_behavior/user/2?pretty

insert image description here

Guess you like

Origin blog.csdn.net/m0_67401134/article/details/126659508