4
我有一個問題,使用批量方法在NEST到索引子記錄到Elasticsearch。Elasticsearch C#NEST IndexMany Children
我使用ElasticSearch 2.3.5和2.4.4 NEST
我映射索引這樣:
myindex
{
"mappings": {
"elasticparent": {},
"elasticchild": {
"_parent": {
"type": elasticparent
}
}
}
}
而且我索引使用IndexMany方法的父對象:
client.IndexMany<elasticparent>(batch, "myindex");
這一切都很好。
我現在想索引使用Index的孩子。這是我迄今爲止所嘗試的:
client.Bulk(s => s.IndexMany(IenumerableOfChild,
(bulkDescriptor, record) =>
bulkDescriptor.Index("myindex").Type("elasticchild").Parent(record.Id)));
孩子和父母共享相同的Id整數。
我沒有收到錯誤,但孩子們永遠不會被編入索引,而且文件也不會被添加到總索引計數中。
分別指引他們工作:
foreach (var child in IenumerableOfChild
{
client.Index(child, descriptor => descriptor
.Parent(child.Id.ToString()).Index("myindex"));
}
我不想質量指數分別數額。我想用IndexMany批量索引子記錄。有人能指出我做錯了什麼嗎?
很高興你已經到了它的底部。玩一下批量大小以及您可以爲羣集發送的併發批量請求的數量。 –
謝謝。我沒有想過併發請求。這是一個非常好的主意。可能是批量異步? –
已有一個基於'BulkAsync'方法的任務,因此您可以使用它們的集合來發出併發批量請求。看看'master'中的'BulkAll',瞭解如何實現這一點 - https://github.com/elastic/elasticsearch-net/blob/52541d0a472b6be85f5fe5d966374655671a3d37/src/Nest/Document/Multiple/BulkAll/ElasticClient -BulkAll.cs。以下是關於該問題的PR,對此問題進行了一些討論:https://github.com/elastic/elasticsearch-net/pull/2162 –