【发布时间】:2021-02-02 09:23:18
【问题描述】:
我是 .NET 的新手。我在使用 RESTful API 将文档插入 Elasticsearch 时遇到问题。触发IndexAsync 方法时出现以下错误。
无法从用法中推断出方法“ElasticClient.IndexAsync(IIndexRequest, CancellationToken)”的类型参数。尝试明确指定类型参数。
下面是我实际运行的代码。任何指向正确方向的指针都表示赞赏。
// add new record into elastic
public bool Add(T item)
{
try
{
//_client.IndexDocument(item);
return _client.Index(item).Created;
}
catch (Exception ex)
{
throw ex;
}
}
// add new record into elastic in an asynchronous manner
public async Task<bool> AddAsync(T item)
{
try
{
var response = await _client.IndexAsync(item);
return response.Created;
}
catch (Exception ex)
{
throw ex;
}
}
【问题讨论】:
-
阅读How to Ask 并详细说明您是如何“陷入困境”的。究竟是什么问题?
标签: c# .net elasticsearch nest