【发布时间】:2017-01-07 03:33:31
【问题描述】:
我在使用 NEST 中的批量方法将子记录索引到 Elasticsearch 时遇到问题。
我正在使用 ElasticSearch 2.3.5 和 NEST 2.4.4
我已经这样映射了一个索引:
myindex
{
"mappings": {
"elasticparent": {},
"elasticchild": {
"_parent": {
"type": elasticparent
}
}
}
}
我已经使用 IndexMany 方法为父对象建立了索引:
client.IndexMany<elasticparent>(batch, "myindex");
这一切都很好。
我现在想使用 IndexMany 为孩子编制索引。到目前为止,这是我尝试过的:
client.Bulk(s => s.IndexMany(IenumerableOfChild,
(bulkDescriptor, record) =>
bulkDescriptor.Index("myindex").Type("elasticchild").Parent(record.Id)));
child 和 parent 共享相同的 Id 整数。
我没有收到错误,但孩子永远不会被索引,并且文档永远不会被添加到总索引计数中。
单独为它们编制索引工作:
foreach (var child in IenumerableOfChild
{
client.Index(child, descriptor => descriptor
.Parent(child.Id.ToString()).Index("myindex"));
}
我不想单独索引质量数量。我想使用 IndexMany 批量索引子记录。有人能指出我做错了什么吗?
【问题讨论】:
标签: c# elasticsearch indexing parent-child nest