我正在使用 Nodejs 将一些数据索引到 Elasticsearch(托管在 kubernetes 上),我正在使用 client.create()
方法在 Elasticsearch 中索引文档。如果我在本地主机和 kubernetes Elasticsearch 端点上运行代码,一切正常。但是在我尝试索引文档时部署相同的代码后,出现错误:
"[invalid_type_name_exception] Document mapping type name can't start with '_', found: [_create] :: {"path":"/index_name/_create/docId"]".
Elasticsearch 版本“6.3.0”和 node_module 版本“^16.0.0”。 此外,它最初正在工作,但从过去几天开始停止工作。 我认为问题出在某些兼容性和配置上,有人可以帮忙吗?
我尝试使用 client.index 而不是 client.create,它工作正常。 我已经匹配了本地和服务器上的所有配置和兼容性文件。我觉得一切都很好。
const elasticsearchDoc = {
index: "school",
type: "_doc",
id: 12345,
body: { name:"raj",marks:40 }
};
const result = await client.create(elasticsearchDoc);
...
最佳答案
我认为问题在于您使用的是 old JS client库而不是 the new one .
对于 16.0.0,您需要 to explicitely set the apiVersion
parameter到 6.x 版本,因为 7.0 是默认版本,这可能就是您看到此错误的原因(因为您使用的是 ES 6.3.0):
apiVersion: 6.7
关于node.js - 如何修复 "Document mapping type name can' t 从 '_' 开始,找到 : [_create]_"elasticsearch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56964196/