Elasticsearch C # NEST IndexMany Children

I am having a problem using the bulk method method in NEST to index child records in Elasticsearch.

I am using ElasticSearch 2.3.5 and NEST 2.4.4

I displayed the index as such:

    myindex
    {
     "mappings": {
       "elasticparent": {},
        "elasticchild": {
          "_parent": {
            "type": elasticparent
          }
        }
      }
    }

And I indexed the parent objects using the IndexMany method :

    client.IndexMany<elasticparent>(batch, "myindex");

It all works well.

Now I would like to index children using IndexMany . Here is what I have tried so far:

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

The child and parent have the same integer Id.

I do not get an error, but children are never indexed and documents are not added to the general indexed account.

Indexing them individually works :

    foreach (var child in IenumerableOfChild
            {

                client.Index(child, descriptor => descriptor
                 .Parent(child.Id.ToString()).Index("myindex"));
            }

. IndexMany . - , ?

+4
2

, Elastic Server . 1000 , !

    foreach (IEnumerable<object> batch in objects.Batch(1000))
            {
                var indexResponse = client.Bulk(s => s.IndexMany(batch,
                                         (bulkDescriptor, record) =>
                                           bulkDescriptor.Index("myindex").Parent(record.Id.ToString()).Document(record).Type("elasticchild").Id(record.Id.ToString())));

                Console.WriteLine(indexResponse);
            }
+4

. . : -

var indexResponse = elasticService.Bulk(s => s.IndexMany<Child> 
                                      (childreslist, 
 (bulkDescriptor, record) => bulkDescriptor.Index(Constants.INDEX_NAME)
                                                                    .Type("_doc")
                                                                    .Routing(new 
            Routing(record.id.ToString()))
                                                                ));                  
0

Source: https://habr.com/ru/post/1653036/


All Articles