es 更新

在 ES 7 中新增索引:

PUT student
{
  "mappings" : {
    "properties" : {
      "name" : {
        "type" : "keyword"
      },
      "age" : {
        "type" : "integer"
      }
    }
  },
  "settings" : {
    "index" : {
      "number_of_shards" : 1,
      "number_of_replicas" : 0
    }
  }
}

 

使用 _update 更新文档


# 请求1 POST student/_doc/2 { "name": "李四" } # 请求2: 新增 age POST student/_doc/2/_update { "doc": { "age": 10 } } # 查询 GET student/_doc/2 # 查询结果 { "_index" : "student", "_type" : "_doc", "_id" : "2", "_version" : 6, "_seq_no" : 6, "_primary_term" : 1, "found" : true, "_source" : { "name" : "李四", "age" : 10 } }
posted @ 2021-01-29 16:07  agang_19  阅读(116)  评论(0编辑  收藏  举报