Elasticsearch常用基础操作

1、获得集群中的节点列表:

curl 'localhost:9200/_cat/nodes?v'

2、获得所有索引:

curl 'localhost:9200/_cat/indices?v'

3、创建指定文档,并索引到指定索引和类型

#                  索引  类型
1 curl -XPUT 'localhost:9200/customer/external/1?pretty' -d ' 2 { 3 "name": "John Doe" 4 }'

4、取出指定文档

curl -XGET 'localhost:9200/customer/external/1?pretty'

5、删除指定文档

curl -XDELETE 'localhost:9200/customer/external/2?pretty' 

6、删除指定索引

curl -XDELETE 'localhost:9200/customer?pretty'

7、修改指定文档——直接使用添加的方式“-d”指定覆盖

1 curl -XPUT 'localhost:9200/customer/external/1?pretty' -d '
2             {
3               "name": "John Doe"
4             }'

8、更新文档

1 curl -XPOST 'localhost:9200/customer/external/1/_update?pretty' -d '
2         {
3           "doc": { "name": "Jane Doe" }
4         }'
作者:穷开心y
出处:https://home.cnblogs.com/u/hcy-fly/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/hcy-fly/p/7978520.html