【问题标题】:elasticsearch - unable to update a dense vector field through update APIelasticsearch - 无法通过更新 API 更新密集矢量场
【发布时间】:2021-02-06 06:34:18
【问题描述】:

您好,我正在尝试更新其中一个 es 文档中的密集矢量数据,并且无法使用映射中不存在的错误字段进行更新,即使该字段存在

映射:

{
  "sidx-4111c0fc-a8ba-523c-9851-34a2b803643b" : {
    "mappings" : {
      "properties" : {
       
        "dense_vector_field" : {
          "type" : "dense_vector",
          "dims" : 768
        },
       
        "searchResultPreview" : {
          "type" : "text",
          "fields" : {
            "search_result_preview" : {
              "type" : "keyword"
            }
          }
        }
      }
    }
  }

查询-

POST /sidx-4111c0fc-a8ba-523c-9851-34a2b803643b/_update/xLVRVHUB3NwnlUUimDIR
{
  "dense_vector_field": [...]
}

错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "x_content_parse_exception",
        "reason" : "[2:3] [UpdateRequest] unknown field [dense_vector_field]"
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[2:3] [UpdateRequest] unknown field [dense_vector_field]"
  },
  "status" : 400
}

我错过了什么吗?

编辑 - 由于尺寸太大而忽略提及矢量数据

【问题讨论】:

    标签: elasticsearch elastic-stack elasticsearch-dsl


    【解决方案1】:

    问题在于_update API 需要docscript,因此您需要这样做:

    POST /sidx-4111c0fc-a8ba-523c-9851-34a2b803643b/_update/xLVRVHUB3NwnlUUimDIR
    {
      "doc": {
        "dense_vector_field": [...]
      }
    }
    

    或者这样使用script:

    POST /sidx-4111c0fc-a8ba-523c-9851-34a2b803643b/_update/xLVRVHUB3NwnlUUimDIR
    {
      "script": {
        "source": "ctx._source.dense_vector_field = params.vector",
        "params": {
          "vector": [...]
        }
      } 
    }
    

    【讨论】:

      猜你喜欢
      • 2017-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-18
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多