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         }'
posted @ 2017-12-04 18:49  穷开心y  阅读(272)  评论(0编辑  收藏  举报