无法使用弹性搜索查询更新 phone 号码,获取 mapper_parsing_exception

Unable to update phone number using elastic search query, getting mapper_parsing_exception

我正在尝试使用以下查询更新 phone 号码,但我得到“mapper_parsing_exception。请参阅下面的代码。

查询:

POST /ps/_update/alOKenkBHofR-Ip1hPcv
{
  "doc": {
    "ph": {
      "na": null,
      "nu": "877842376",
      "cc": "91",
      "ex": null,
      "pt": "M"
    },
    "mdt": "20210615T044700.714Z"
  }

响应:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse field [ph] of type [text] in document with id 'alOKenkBHofR-Ip1hPcv'. Preview of field's value: '{cc=91, na=null, ex=null, pt=M, nu=877842376}'"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse field [ph] of type [text] in document with id 'alOKenkBHofR-Ip1hPcv'. Preview of field's value: '{cc=91, na=null, ex=null, pt=M, nu=877842376}'",
    "caused_by" : {
      "type" : "illegal_state_exception",
      "reason" : "Can't get text on a START_OBJECT at 1:3558"
    }
  },
  "status" : 400
}

//代码

 Document document = Document.create();
            Map<String, Object> map = new Phone.ToMap().convert((Phone) value);
            document.put(key, map);

        UpdateQuery updateQuery = UpdateQuery.builder(id).withDocument(document).build();
        UpdateResponse updateResponse = operations.update(updateQuery, indexCoordinates());
        Result result = updateResponse.getResult();

您的 phbi 对象的一部分,因此要更新您的文档,您应该执行以下查询:

POST /ps/_update/alOKenkBHofR-Ip1hPcv
{
  "doc": {
    "bi"{
        "ph": {
          "na": null,
          "nu": "877842376",
          "cc": "91",
          "ex": null,
          "pt": "M"
         }
    },
    "mdt": "20210615T044700.714Z"
  }