您的json不适合Elasticsearch批量操作。请参阅文档。
在批量请求中,每个数据对象都应带有命令,因为单个批量请求可以包含插入,更新或删除,而不仅仅是插入。所以你的json应该看起来像
{ "index" : { "_index" : "twitter", "_type" : "tweets" } }n {'name':'test104','lastname':'test107','id':'104'}n { "index" : { "_index" : "twitter", "_type" : "tweets" } }n {'name':'test105','lastname':'test108','id':'105'}n { "index" : { "_index" : "twitter", "_type" : "tweets" } }n {'name':'test106','lastname':'test109','id':'106'}n为了减少重复命令的开销,您可以将一些参数移至请求uri。然后json可以更短:
{ "index" : { } }n {'name':'test104','lastname':'test107','id':'104'}n在IRawElasticClient中,这意味着将它们移至BulkPost参数。
var result = client.Raw.BulkPost(new { twitter }, "twitter", "tweets");


