private IConnectionSettingsValues InitialiseConnectionSettings()
        {
            var config = _configProvider.Get <ElasticConfig>();

            var connectionSettings = new Nest
                                     .ConnectionSettings(new SingleNodeConnectionPool(new Uri(config.Url)))
                                     .ThrowExceptions();

            connectionSettings.BasicAuthentication(config.UserName, config.Password);

            return(connectionSettings);
        }
Beispiel #2
0
        protected static ElasticClient GetESClient(PluginConfig pluginConfig)
        {
            using (ConnectionSettings connection = new Nest.ConnectionSettings(new Uri(pluginConfig.ElasticsearchUrl)))
            {
                if (pluginConfig.SecurityType == "basic" && pluginConfig.Username != null && pluginConfig.Password != null)
                {
                    connection.BasicAuthentication(pluginConfig.Username, pluginConfig.Password);
                }

                connection.DefaultIndex("active-homeseer-index");

                ElasticClient client = new Nest.ElasticClient(connection);
                return(client);
            }
        }