我在使用批量API(C#NEST v5.4)插入文档时遇到了一个问题。我有一个文档数组,数组中有我的ID。
我的代码是:
documents = documents .ToArray();
Client.Bulk(bd =>
bd.IndexMany(documents,
(descriptor, s) => descriptor.Index(indexName)));
如何使用描述符手动插入_id?
先谢了!
我在使用批量API(C#NEST v5.4)插入文档时遇到了一个问题。我有一个文档数组,数组中有我的ID。
我的代码是:
documents = documents .ToArray();
Client.Bulk(bd =>
bd.IndexMany(documents,
(descriptor, s) => descriptor.Index(indexName)));
如何使用描述符手动插入_id?
先谢了!
2条答案
按热度按时间roqulrg31#
可以像在
BulkDescriptor
上设置索引名称那样设置_id
。例如,使用递增计数器设置ID
生成以下请求
anhgbhbe2#
下面是一个基于GUID类型字段的例子,但它也可以是任何其他类型,我们可以在elasticsearch中指定要作为文档_id的类的字段。
基于上述POCO的示例
相同的代码异步