【原创】elasticsearch入门命令 (2)

响应

ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name 192.168.141.129 24 89 2 0.00 0.10 0.18 mdi * 7hyiUY2 列出所有的索引 curl -XGET 192.168.141.129:9200/_cat/indices?v&pretty GET /_cat/indices?v

响应

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open .kibana e9VV3rJSTduGLdcwqg2ZKw 1 0 1 0 4kb 4kb 创建索引 curl -XPUT 192.168.141.129:9200/customer?pretty PUT /customer?pretty

响应

{ "acknowledged": true, "shards_acknowledged": true, "index": "customer" } 删除索引 curl -XDELETE 192.168.141.129:9200/customer?pretty DELETE /customer?pretty

响应

{ "acknowledged": true } 创建文档 # 无id curl -XPOST 192.168.141.129:9200/customer/doc?pretty -H 'Content-Type: application/json' -d '{"name": "John Doe"}' POST /customer/doc?pretty { "name": "John Doe" } # 有id curl -XPUT 192.168.141.129:9200/customer/doc/1/_create?pretty -H 'Content-Type: application/json' -d '{"name": "John Doe"}' PUT /customer/doc/1/_create { "name": "John Doe" }

响应

{ "_index": "customer", "_type": "doc", "_id": "6zaU0WUBANcevg0yn4q5", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 2, "_primary_term": 1 } { "_index": "customer", "_type": "doc", "_id": "5", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 0, "_primary_term": 1 } 更新文档 curl -XPOST 192.168.141.129:9200/customer/doc/1/_update?pretty -H 'Content-Type: application/json' -d '{"doc": { "name": "Jane Doe" }}' POST /customer/doc/1/_update?pretty { "doc": { "name": "Jane Doe" } }

响应

{ "_index" : "customer", "_type" : "doc", "_id" : "1", "_version" : 27, "result" : "updated", "_shards" : { "total" : 2, "successful" : 1, "failed" : 0 }, "_seq_no" : 27, "_primary_term" : 1 } 查看文档 curl -XGET 192.168.141.129:9200/customer/doc/1?pretty GET /customer/doc/1?pretty

响应

{ "_index" : "customer", "_type" : "doc", "_id" : "1", "_version" : 1, "found" : true, "_source" : { "name" : "John Doe" } } 删除文档 curl -XDELETE 192.168.141.129:9200/customer/doc/2?pretty DELETE /customer/doc/2?pretty

响应

{ "_index": "customer", "_type": "doc", "_id": "2", "_version": 2, "result": "deleted", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 3, "_primary_term": 1 } 批处理 curl -XPOST '192.168.141.129:9200/customer/doc/_bulk?pretty&pretty' -H 'Content-Type: application/json' -d ' {"index":{"_id":"1"}} {"name": "John Doe" } {"index":{"_id":"2"}} {"name": "Jane Doe" } ' POST /customer/doc/_bulk?pretty {"index":{"_id":"1"}} {"name": "John Doe" } {"index":{"_id":"2"}} {"name": "Jane Doe" }

响应

{ "took": 9, "errors": false, "items": [ { "index": { "_index": "customer", "_type": "doc", "_id": "1", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 29, "_primary_term": 1, "status": 201 } }, { "index": { "_index": "customer", "_type": "doc", "_id": "2", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 4, "_primary_term": 1, "status": 201 } } ] } 搜索API

闷头造测试数据中,api命令还未学习整理。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpjpys.html