elasticsearch,Javascript,Node.js,Json,elasticsearch" /> elasticsearch,Javascript,Node.js,Json,elasticsearch" />

Javascript 更新elasticsearch中的索引时出错

Javascript 更新elasticsearch中的索引时出错,javascript,node.js,json,elasticsearch,Javascript,Node.js,Json,elasticsearch,使用elasticsearch更新索引时,在elasticsearch中发出更新请求时,将上述错误作为响应获取,而下面是我传递的JSON数据 '{"error":{"root_cause":[{"type":"invalid_type_name_exception","reason":"Document mapping type name can\'t start with \'_\', found: [_update]"}],"type":"invalid_type_name_exceptio

使用elasticsearch更新索引时,在elasticsearch中发出更新请求时,将上述错误作为响应获取,而下面是我传递的JSON数据

'{"error":{"root_cause":[{"type":"invalid_type_name_exception","reason":"Document mapping type name can\'t start with \'_\', found: [_update]"}],"type":"invalid_type_name_exception","reason":"Document mapping type name can\'t start with \'_\', found: [_update]"},"status":400}',
这也是我要传递的函数

 { name: 'TESTIN ONE (3)',
  id: 'PUZb8739273HD83DGE',
  titles:
   [ { id: 21, title: 'FALSELY ACCUSED' },
     { id: 21, title: 'FALSELY ACCUSED' },
     { id: 23, title: undefined } ] }
在这个函数的参数中,我传递的是JSON

错误

项目的价值

"error": {
      "root_cause": [
        {
          "type": "document_missing_exception",
          "reason": "[_doc][5d8de6a0806590a27895f971]: document missing",
          "index_uuid": "j26lRI1UTJuJmHw_GuPSxg",
          "shard": "0",
          "index": "docprojectnew"
        }
      ],
      "type": "document_missing_exception",
      "reason": "[_doc][5d8de6a0806590a27895f971]: document missing",
      "index_uuid": "j26lRI1UTJuJmHw_GuPSxg",
      "shard": "0",
      "index": "docprojectnew"
    },
    "status": 404   }
请尝试下面的代码

{ projectName:
   'NEW UPDATE DATA (3)',
  id: '5d8de6a0806590a27895f971',
  titles:
   [ { id: 5d88afc8e9896c1ca7f2c065, title: 'FALSELY ACCUSED' },
     { id: 5d88afc8e9896c1ca7f2c065, title: 'FALSELY ACCUSED' },
     { id: 5d5eeb2ec300364d48764f78, title: undefined } ] }

您使用的Elasticsearch版本是什么?客户端版本与它兼容吗

文档映射类型名称不能以“u”开头。
表明,您使用的是7.0*之前的Elastic,但您的类型:“\u doc”适用于7.*


请参见键入:“\u doc”。你能试试doc而不是doc,看看它是否works@jaspreetchahal同样的Issue@Farhan,您可以尝试从更新函数中删除“type”参数并重试吗?@AbhilashBolla也这样做了,但没有luck@jaspreetchahal
[UpdateRequest]未知字段[名称],未找到解析器
在最新的
[UpdateRequest]未知字段中发现此错误[name],找不到解析器
@Farhan您能粘贴项目的完整错误和值吗?根据“文档缺失异常”更新了有问题项目的错误和值的详细信息--您试图更新的文档不存在。您可以使用doc\u as\u upert:true更新文档(如果存在),否则创建一个只需询问ES索引是否已更新,它会添加新的projectName字段,而旧的字段保持不变?是否正确,它应该更改现有的字段?
{ projectName:
   'NEW UPDATE DATA (3)',
  id: '5d8de6a0806590a27895f971',
  titles:
   [ { id: 5d88afc8e9896c1ca7f2c065, title: 'FALSELY ACCUSED' },
     { id: 5d88afc8e9896c1ca7f2c065, title: 'FALSELY ACCUSED' },
     { id: 5d5eeb2ec300364d48764f78, title: undefined } ] }
const result = await client.update({
   index: "updatedproject",
   type: "_doc",
   id: project.id,
   refresh: 'true',
   body: {
     doc: project
   }
});
return result;