小编P L*_*Lab的帖子

Elasticsearch C# NEST 索引很多孩子

我在使用NEST 中的批量方法子记录索引到 Elasticsearch 时遇到问题。

我正在使用 ElasticSearch 2.3.5 和 NEST 2.4.4

我已经映射了一个索引:

    myindex
    {
     "mappings": {
       "elasticparent": {},
        "elasticchild": {
          "_parent": {
            "type": elasticparent
          }
        }
      }
    }
Run Code Online (Sandbox Code Playgroud)

我已经使用IndexMany方法索引了父对象:

    client.IndexMany<elasticparent>(batch, "myindex");
Run Code Online (Sandbox Code Playgroud)

这一切都很好。

我现在想使用IndexMany索引孩子。这是我迄今为止尝试过的:

     client.Bulk(s => s.IndexMany(IenumerableOfChild,
                                  (bulkDescriptor, record) =>
                                  bulkDescriptor.Index("myindex").Type("elasticchild").Parent(record.Id)));
Run Code Online (Sandbox Code Playgroud)

子级和父级共享相同的 Id 整数。

我没有收到错误消息,但是子项永远不会被索引,并且文档永远不会添加到总索引计数中。

单独索引它们是有效的

    foreach (var child in IenumerableOfChild
            {

                client.Index(child, descriptor => descriptor
                 .Parent(child.Id.ToString()).Index("myindex"));
            }
Run Code Online (Sandbox Code Playgroud)

我不想单独索引质量。我想使用 IndexMany 对子记录进行批量索引。有人可以指出我做错了什么吗?

c# indexing parent-child elasticsearch nest

7
推荐指数
1
解决办法
3748
查看次数

标签 统计

c# ×1

elasticsearch ×1

indexing ×1

nest ×1

parent-child ×1