Elasticsearch CRUD
Elasticsearch 版本 6.6.0
- 新增文檔
PUT /user_index/user/1
{
"user_name":"zhangsan",
"age":"10"
}
put /index/type/id
1. index : user_index
2. type: user
3. id : 1
新增文檔孵班,會直接創(chuàng)建 index 立美,不用單獨創(chuàng)建
- 查詢 es 中的 index 情況
GET /_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open kibana_sample_data_logs PEvwDvYfTnqBy2yOMhzZ-Q 1 0 14005 0 11.6mb 11.6mb
yellow open hello-index OOqSjcFjSAWnb20NZqHZYQ 5 1 0 0 1.2kb 1.2kb
yellow open account n_Noi5erQVylSarsHRoADg 5 1 7 0 59.2kb 59.2kb
yellow open ecommerce Nai9KPdiTg6-ccGPulceDg 5 1 1 0 6.7kb 6.7kb
green open .kibana_1 Bu2a6YTiTciyw3T5RdAzWQ 1 0 18 0 78.5kb 78.5kb
yellow open user_index VCgcUaMhS5CKMORoLb5Aaw 5 1 1 0 4.8kb 4.8kb
yellow open customer 1gX8K6VxQy2nywEqAdYfBw 5 1 1 0 4.5kb 4.5kb
- 查詢文檔
GET /user_index/user/1 ## 查詢 id = 1 的文檔
{
"_index" : "user_index",
"_type" : "user",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"user_name" : "zhangsan",
"age" : "10"
}
}
- 刪除
DELETE /user_index/user/1
- 查詢所有
GET /user_index/user/_search