Elasticsearch-curl进行简单操作

来源:互联网 发布:Mac用什么浏览器好 编辑:程序博客网 时间:2024/06/05 07:08

创建Index

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

创建类型并添加数据

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

获取文档

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

删除索引

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

命令格式

curl -X<REST Verb> <Node>:<Port>/<Index>/<Type>/<ID>

更新命令

curl -XPOST 'localhost:9200/customer/external/1/_update?pretty' -d '{  "doc": { "name": "Jane Doe" }}'curl -XPOST 'localhost:9200/customer/external/1/_update?pretty' -d '{  "script" : "ctx._source.age += 5"}'

删除文档

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

批量操作

curl -XPOST 'localhost:9200/customer/external/_bulk?pretty' -d '{"index":{"_id":"1"}}{"name": "John Doe" }{"index":{"_id":"2"}}{"name": "Jane Doe" }'curl -XPOST 'localhost:9200/customer/external/_bulk?pretty' -d '{"update":{"_id":"1"}}{"doc": { "name": "John Doe becomes Jane Doe" } }{"delete":{"_id":"2"}}'
0 0
原创粉丝点击