我尝试将 100k 产品添加到 elasticsearch,但是当我尝试时我得到:{“验证失败:1:没有添加请求;”}
我的代码:
var Node = new Uri("......");
var ConnectionPool = new SniffingConnectionPool(new[] { Node });
var Config = new ConnectionConfiguration(ConnectionPool)
.SniffOnConnectionFault(false)
.SniffOnStartup(false)
.SniffLifeSpan(TimeSpan.FromMinutes(10));
var Client = new ElasticsearchClient(Config);
var AllProducts = Product.GetProducts();
var SPl = AllProducts.Split(100); // Split into 100 collections/requests
var COll = new List<ElasticsearchResponse<DynamicDictionary>>();
foreach (var I in SPl)
{
var Descriptor = new BulkDescriptor();
foreach (var Product in I)
{
Descriptor.Index<Product>(op => op.Document(Product));
}
COll.Add(Client.Bulk(Descriptor));
}
AllProducts 包含此对象的列表:
public class Product
{
public int AffiliateNr { get; set; }
public string AffiliateProductId { get; set; }
public int BrandNr { get; set; }
public string Currency { get; set; }
public string IndexId { get; set; }
public decimal Price { get; set; }
public long ProductNr { get; set; }
public string Title { get; set; }
}
所以,
- 我在哪里可以设置索引的名称?
- 为什么我得到,验证失败:1:没有添加请求;?
- IndexId 是我的产品 ID。我如何告诉 Elasticsearch 使用这个 id?或者我必须指定一个ID?