【发布时间】:2016-04-16 15:36:36
【问题描述】:
我正在使用版本 2.1 和 2.0 (alpha) 客户端和 Nest C# 客户端...我正在尝试批量插入一些记录,但是,服务器返回错误。我正在使用与 Linux 服务器通信的 Windows 客户端上的客户端(但我认为这并不重要)。
public static void AddQuestionsToElasticSearch()
{
var es = new ElasticsearchClient(new ConnectionConfiguration(
new Uri("http://elasticserver:9200"))
);
var foobars = new FooBar().Parse();
var descriptor = new BulkDescriptor();
descriptor.CreateMany<FooBar>(foobars, (bd, q) => bd.Id(q.Id.ToString()).Index("foobars"));
Console.WriteLine($"Inserting foobars into ES...");
var sw = new Stopwatch();
sw.Start();
var result = es.Bulk<FooBar>(descriptor);
sw.Stop();
Console.WriteLine($"Finished inserting foobars {GetTimeTaken(sw.Elapsed)}");
}
更新 - 错误信息
我得到的错误是在 Bulk() 方法返回的响应中......返回的 BulkResponse 的两个属性是:
OriginalException: "远程服务器返回错误:(400) Bad Request"
ServerError.Error:“验证失败:1:未添加请求”
【问题讨论】:
-
更新问题有错误
-
你确定
new FooBar().Parse();实际上返回了任何物品吗? -
是的。它确实返回有效数据....简单地模拟数据源 new []{new FooBar(), new FooBar(), .... };
标签: elasticsearch nest elasticsearch-net