最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

elasticsearch中更新索引时出错

运维笔记admin25浏览0评论

elasticsearch中更新索引时出错

elasticsearch中更新索引时出错

'{"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}',

[在使用elasticsearch更新索引时,在elasticsearch中发出更新请求时得到上述错误,而下面是我传递的JSON数据。

 { name: 'TESTIN ONE (3)',
  id: 'PUZb8739273HD83DGE',
  titles:
   [ { id: 21, title: 'FALSELY ACCUSED' },
     { id: 21, title: 'FALSELY ACCUSED' },
     { id: 23, title: undefined } ] }

也是我正在通过的功能

updateProjectIndex = async (project) => {
    try {
        const result = await client.update({
            index: "updatedproject",
            type: "_doc",
            id: project.id,
            refresh: 'true',
            body: project,
        });
        return result;
    }
    catch (e) {
        console.log(e);
    }
}

并且在此函数的参数中,我正在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   }

project的值

{ 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;
发布评论

评论列表(0)

  1. 暂无评论