当我使用 _id 设置将文档添加到 elasticsearch 时,我得到:
Field [_id] is a metadata field and cannot be added inside a document. Use the index API request parameters.
使用 client.bulk
const body = dataset.flatMap(doc => [{ index: { _index: 'myindex' } }, doc])
const { body: bulkResponse } = await client.bulk({ refresh: true, body })
我没有看到在参数中放置 _id 的地方。
https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html
我应该使用不同的方法吗?
Thanks.
它需要位于命令部分内,但您还需要将其从源文档中删除doc
:
here
|
v
const body = dataset.flatMap(doc => [{ index: { _index: 'myindex', _id: doc._id } }, doc])
const { body: bulkResponse } = await client.bulk({ refresh: true, body })
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)