1、如下:更新改类型未doc(文档)的全局字段数据

注意:如果你使用的是上面的语句,但是只写了id和title并赋值,图片上其他字段没有填写,执行命令后,则会把原文档中的其他字段都给删除了,你会发现查询出来的结果中除了id和title,其他字段都没有了,如下:

2、 如果只是想更新文档中某个字段,请使用以下语法,结果如下

注意:请求方式是Post,以及命令函数:_update
robot-demand是索引名,_doc是定义的类型名称,此处是代表的文档类型,
ae4801ee-5b1d-6b33-876d-3a0d942e8a3e是文档的id
POST robot-demand/_doc/ae4801ee-5b1d-6b33-876d-3a0d942e8a3e/_update
{
  "doc":{
      "title" : "金刚石砂轮B"
  }
}
3、总结:更新全局文档使用如下语法
PUT /索引名/[类型名]/文档id
{
"name":"666",
"age":28
}
PUT robot-demand/_doc/ae4801ee-5b1d-6b33-876d-3a0d942e8a3e
{
  "id" : "ae4801ee-5b1d-6b33-876d-3a0d942e8a3e",
  "title" : "金刚石砂轮",
  "categoryLabel" : "特种机器人",
  "demandTypeValue" : "rentalRequirements",
  "releaseTime" : "2023-09-30T12:00:00",
  "deadline" : "2023-12-30T00:00:00",
  "provinceCode" : 410000,
  "companyName" : "郑州金谷粮食机械工程设备有限公司",
  "industryGroup" : "ad2e8966-c550-cd09-7ccb-3a0d99a0000b",
  "industrySubGroup" : "ad2e8966-c550-cd09-7ccb-3a0d99a00039",
  "industrySpecific" : "ad2e8966-c550-cd09-7ccb-3a0d99a00063"
}
PUT robot-demand/_doc/ae4801ee-5b1d-6b33-876d-3a0d942e8a3e?refresh=wait_for
{
  "id" : "ae4801ee-5b1d-6b33-876d-3a0d942e8a3e",
  "title" : "金刚石砂轮",
  "categoryLabel" : "特种机器人",
  "demandTypeValue" : "rentalRequirements",
  "releaseTime" : "2023-09-30T12:00:00",
  "deadline" : "2023-12-30T00:00:00",
  "provinceCode" : 410000,
  "companyName" : "郑州金谷粮食机械工程设备有限公司",
  "industryGroup" : "ad2e8966-c550-cd09-7ccb-3a0d99a0000b",
  "industrySubGroup" : "ad2e8966-c550-cd09-7ccb-3a0d99a00039",
  "industrySpecific" : "ad2e8966-c550-cd09-7ccb-3a0d99a00063"
}更新单个字段使用post和_update方式
POST /索引名/[类型名]/文档id/_update
{
"doc":{
"name":"666"
}
}
例如:
POST robot-demand/_doc/ae4801ee-5b1d-6b33-876d-3a0d942e8a3e/_update
{
  "doc":{
      "title" : "金刚石砂轮B"
  }
}最后查询语句语法: GET 索引名/_search
--不带参数的genuine索引名查询全部
GET robot-demand/_search
--查询全部(带查询参数的方式)
GET robot-demand/_search
{
  "query": {
        "match_all": {}
    }
}


















