Reputation: 47
I am currently updating our elasticsearch code to use the built-in Connection Pooling offered by Nest's IElasticClient. So before we were using
var settings = new ConnectionSettings(new Uri(connString));
var esClient = new ElasticClient(settings);
and now I want to be able to pass in a configured connection pool (as mentioned in Nest's docs) like so
var connectionPool = new SniffingConnectionPool(new[] { new Uri(connString});
var config = new ConnectionConfiguration(connectionPool);
.SniffOnConnectionFault(false)
.SniffOnStartup(false)
.SniffLifeSpan(TimeSpan.FromMinutes(1));
var client = new ElasticsearchClient(config);
However, they use the raw ElasticsearchClient to do this. Nest's ElasticClient constructor does not offer the ability to pass in a ConnectionConfiguration, only a ConnectionPool.
Does anyone know how to use a ConnectionConfiguration with an ElasticClient?
Upvotes: 2
Views: 597
Reputation: 6357
You can use Nest.ConnectionSettings
for this. See the code below:
var connectionPool = new SniffingConnectionPool(new[] { new Uri(connString});
var config = new ConnectionSettings(connectionPool)
.SniffOnConnectionFault(false)
.SniffOnStartup(false)
.SniffLifeSpan(TimeSpan.FromMinutes(1));
var client = new ElasticClient(config);
Upvotes: 1