ES简单使用
curl -XGET ‘10.150.19.99:9200/_cat/nodes?v&pretty’ 查看集群节点
curl -XGET “10.150.19.99:9200/_cat/health?v” 查看集群状态
curl -XGET “10.150.19.99:9200/_cat/indices?v&pretty” 查看索引
curl -XPUT “10.150.19.99:9200/customer?pretty&pretty” 创建一个索引
curl -XPUT “10.150.19.99:9200/customer/doc/1?pretty&pretty” -H ‘Content-Type: application/json’ -d ‘{“name”: “John Doe”}’ 在索引添加内容
curl -XGET “10.150.19.99:9200/customer/doc/1?pretty&pretty” 查看索引的内容
curl -XDELETE “10.150.19.99:9200/customer/doc/1?pretty&pretty” 删除索引
PUT /customer
PUT /customer/doc/1
{
“name”: “John Doe”
}
GET /customer/doc/1
DELETE /customer
curl -XPOST ‘10.150.19.99:9200/customer/doc/1/_update?pretty&pretty’ -H ‘Content-Type: application/json’ -d’
{
“doc”: { “name”: “Jane Doe” }
}
‘ __update更新索引的内容
如果要批量加入多条数据怎么办呢?这时用到bulkapi
curl -XPOST ‘localhost:9200/customer/doc/_bulk?pretty&pretty’ -H ‘Content-Type: application/json’ -d’
{“index”:{“_id”:”1”}}
{“name”: “John Doe” }
{“index”:{“_id”:”2”}}
{“name”: “Jane Doe” }
‘
