public ElasticsearchClientOperation(ElasticsearchClientOption operation)
        {
            var node   = new Uri($"http://{operation.Hostname}:{operation.Port.ToString()}");
            var config = new ConnectionConfiguration(node);

            if (!string.IsNullOrEmpty(operation.Username))
            {
                config = config.BasicAuthentication(operation.Username, operation.Password);
            }

            lowLevelClient = new ElasticLowLevelClient(config);
        }
Exemplo n.º 2
0
        public virtual ElasticsearchClientOption Execute(string connectionString)
        {
            if (!CanHandle(connectionString))
            {
                throw new InvalidOperationException();
            }

            var uri    = new Uri(connectionString);
            var option = new ElasticsearchClientOption(connectionString)
            {
                Hostname = uri.Host,
                Port     = uri.Port == -1 ? 9200 : uri.Port
            };

            if (!string.IsNullOrEmpty(uri.UserInfo))
            {
                option.Username = uri.UserInfo.Split(':')[0];
                option.Password = uri.UserInfo.Split(':')[1];
            }

            return(option);
        }