您可以使用低级客户端来传递原始 json。
var elasticsearchClient = new Elasticsearch.Net.ElasticsearchClient(settings);
var elasticsearchResponse = elasticsearchClient.Index("index", "type", "{\"UserID\":1,\"Username\": \"Test\",\"EmailID\": \"Test@TestElastic.com\"}");
更新
根据文档,试试这个:
var sb = new StringBuilder();
sb.AppendLine("{ \"index\": { \"_index\": \"indexname\", \"_type\": \"type\" }}");
sb.AppendLine("{ \"UserID\":1, \"Username\": \"Test\", \"EmailID\": \"Test@TestElastic.com\" }");
sb.AppendLine("{ \"index\": { \"_index\": \"indexname\", \"_type\": \"type\" }}");
sb.AppendLine("{ \"UserID\":2, \"Username\": \"Test\", \"EmailID\": \"Test@TestElastic.com\" }");
var response = elasticsearchClient.Bulk(sb.ToString());