我是Elastic的新手,所以我有点困惑,我已经在elastic中有一个名为survey的索引,我想在其中添加记录。我知道如何使用BulkAsync完成这项工作
var response = await elasticClient.BulkAsync(b => b
.Index("survey")
.IndexMany(data)
);
但是如果我只插入一条记录,我不知道该怎么做。
发布于 2021-02-04 10:16:34
您可以使用如下所示的Index
方法来完成此操作
await elasticClient.IndexAsync(new Document { }, s => s.Index("survey"));
另一种选择是使用IndexDocumentAsync
,但此方法使用客户端的连接设置中定义的缺省索引
await (new ElasticClient(new ConnectionSettings(new Uri(..)).DefaultIndex("survey")))
.IndexDocumentAsync(new Document { });
https://stackoverflow.com/questions/66041502
复制