When creating a new client instance, is there a difference between the following:
services.AddSingleton<IElasticClient>(new ElasticClient(settings)
and
var client = new ElasticClient(settings)
the variable settings
is var settings = new ConnectionSettings(node)
where node is var node = new Uri("http://localhost:9200")
In first code you are adding your elastic client to DI framework in .net as a singleton instance while in second one you are instantiating new instance of elastic client. If you register your ElasticClient as a singleton service you can do constructor injection to use it whenever you want and you will have one instance in your application while the second approach you will create new object each time. You can look at .net official Dependecy Injection framework here.
.