如何使用 NEST Client 为 Elastic Search 索引 Json 数据?
How to Index Json Data using NEST Client for Elastic Search?
我正在尝试使用 C# NEST 库将 json 字符串文件索引到 Elastic Search。我发现这个 post 是相关的。但是 .Index<string>
处存在语法错误
var indexResponse = _elasticClient.LowLevel.Index<string>("index-name", "type-name", json);
错误是
The type 'string' cannot be used as type parameter 'TResponse' in the
generic type or method
'IElasticLowLevelClient.Index(string, string, PostData,
IndexRequestParameters)'. There is no implicit reference conversion
from 'string'
看看low level client documentation
var pool = new SingleNodeConnectionPool(new Uri($"http://localhost:9200"));
var settings = new ConnectionSettings(pool);
var client = new ElasticClient(settings);
var person = @"{ ""first_name"": ""Russ"", ""last_name"": ""Cam"" }";
var indexResponse = client.LowLevel.Index<StringResponse>("people", "1", person);
string responseString = indexResponse.Body;
我正在尝试使用 C# NEST 库将 json 字符串文件索引到 Elastic Search。我发现这个 post 是相关的。但是 .Index<string>
var indexResponse = _elasticClient.LowLevel.Index<string>("index-name", "type-name", json);
错误是
The type 'string' cannot be used as type parameter 'TResponse' in the generic type or method 'IElasticLowLevelClient.Index(string, string, PostData, IndexRequestParameters)'. There is no implicit reference conversion from 'string'
看看low level client documentation
var pool = new SingleNodeConnectionPool(new Uri($"http://localhost:9200"));
var settings = new ConnectionSettings(pool);
var client = new ElasticClient(settings);
var person = @"{ ""first_name"": ""Russ"", ""last_name"": ""Cam"" }";
var indexResponse = client.LowLevel.Index<StringResponse>("people", "1", person);
string responseString = indexResponse.Body;