【问题标题】:Error while updating an index in elasticsearch在弹性搜索中更新索引时出错
【发布时间】:2020-01-27 14:15:58
【问题描述】:
'{"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 } ] }

【问题讨论】:

  • 类型:“_doc”。你可以试试 doc 代替 _doc 看看它是否有效
  • @jaspreetchahal 相同问题
  • @Farhan,你能不能试试把更新函数中的“type”参数去掉试试?
  • @AbhilashBolla 也这样做了,但没有运气
  • @jaspreetchahal [UpdateRequest] unknown field [name], parser not found 最近遇到了这个错误

标签: javascript node.js json elasticsearch


【解决方案1】:

试试下面的代码

const result = await client.update({
   index: "updatedproject",
   type: "_doc",
   id: project.id,
   refresh: 'true',
   body: {
     doc: project
   }
});
return result;

【讨论】:

  • [UpdateRequest] unknown field [name], parser not found
  • @Farhan 你能粘贴项目的完整错误和价值吗
  • 更新了有关项目的错误和价值的详细信息
  • 根据“文档丢失异常”--您尝试更新的文档不存在。您可以使用 doc_as_upsert: true 更新文档(如果存在),否则创建一个
  • 只是询问ES索引是否更新,它添加了新的projectName字段,旧的保持原样?对不对,应该把现有的改一下吧?
【解决方案2】:

您使用的是哪个版本的 Elasticsearch?客户端版本兼容吗?

Document mapping type name can\'t start with \'_\' 建议您使用 7.0* 之前的 Elastic,但您的类型:“_doc”适用于 7.*。

Removal of mapping types

【讨论】:

    猜你喜欢
    • 2020-08-16
    • 1970-01-01
    • 1970-01-01
    • 2014-09-01
    • 2016-09-21
    • 1970-01-01
    • 2021-11-12
    • 1970-01-01
    • 2016-10-24
    相关资源
    最近更新 更多