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'

1 Answer 1

3

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.