Elasticsearch-CRUD-api

Elasticsearch CRUD

Elasticsearch 版本 6.6.0

  1. 新增文档
 PUT /user_index/user/1
{
  "user_name":"zhangsan",
  "age":"10"
}
put /index/type/id
1. index : user_index
2. type: user
3. id : 1
新增文档,会直接创建 index ,不用单独创建
  1. 查询 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
  1. 查询文档
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"
  }
}

  1. 删除
DELETE /user_index/user/1
  1. 查询所有
GET /user_index/user/_search

你可能感兴趣的:(Elasticsearch-CRUD-api)