0

I am trying to index json string file to Elastic Search using C# NEST library. I found this post which is related. But there is a syntax error at .Index<string>

var indexResponse = _elasticClient.LowLevel.Index<string>("index-name", "type-name", json);

The error is

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'

Steve
  • 2,963
  • 15
  • 61
  • 133

1 Answers1

2

Take a look at the 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;
Russ Cam
  • 124,184
  • 33
  • 204
  • 266