簡體   English   中英

更新 elasticsearch 中的索引時出錯

[英]Error while updating an index in 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 } ] }

這也是我正在通過的 function

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;

您使用的是什么版本的 Elasticsearch? 客戶端版本兼容嗎?

Document mapping type name can\'t start with \'_\' ,這表明您使用的是 7.0* 之前的 Elastic,但您的類型:“_doc”適用於 7.*。

請參閱刪除映射類型

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM