Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ElasticContext"/> class.
        /// </summary>
        /// <param name="connection">The information on how to connect to the ElasticSearch server.</param>
        /// <param name="mapping">The object that helps map queries (optional, defaults to <see cref="TrivialElasticMapping"/>).</param>
        /// <param name="log">The object which logs information (optional, defaults to <see cref="NullLog"/>).</param>
        /// <param name="retryPolicy">The object which controls retry policy for the search (optional, defaults to <see cref="RetryPolicy"/>).</param>
        public ElasticContext(ElasticConnection connection, IElasticMapping mapping = null, ILog log = null, IRetryPolicy retryPolicy = null)
        {
            Argument.EnsureNotNull("connection", connection);

            Connection  = connection;
            Mapping     = mapping ?? new TrivialElasticMapping();
            Log         = log ?? NullLog.Instance;
            RetryPolicy = retryPolicy ?? new RetryPolicy(Log);
        }
        public ElasticQueryProvider(ElasticConnection connection, IElasticMapping mapping, ILog log, IRetryPolicy retryPolicy, string prefix)
        {
            Argument.EnsureNotNull("connection", connection);
            Argument.EnsureNotNull("mapping", mapping);
            Argument.EnsureNotNull("log", log);
            Argument.EnsureNotNull("retryPolicy", retryPolicy);

            Connection  = connection;
            Mapping     = mapping;
            Log         = log;
            RetryPolicy = retryPolicy;
            Prefix      = prefix;
        }
 public static ElasticConnection GetNewConnection(string url, string index = null, TimeSpan? timeout = null, ElasticConnectionOptions options = null)
 {
     var uri = new Uri(url);
     var username = "";
     var password = "";
     if (!string.IsNullOrWhiteSpace(uri.UserInfo))
     {
         var upa = uri.UserInfo.Split(new[] {":"}, StringSplitOptions.RemoveEmptyEntries);
         username = upa[0];
         password = upa[1];
     }
     var connection = new ElasticConnection(uri, username, password, timeout, index, options);
     return connection;
 }
Esempio n. 4
0
        /// <summary>
        /// Create a new ElasticQueryProvider for a given connection, mapping, log, retry policy and field prefix.
        /// </summary>
        /// <param name="connection">Connection to use to connect to Elasticsearch.</param>
        /// <param name="mapping">A mapping to specify how queries and results are translated.</param>
        /// <param name="log">A log to receive any information or debugging messages.</param>
        /// <param name="retryPolicy">A policy to describe how to handle network issues.</param>
        public ElasticQueryProvider(ElasticConnection connection, IElasticMapping mapping, ILog log, IRetryPolicy retryPolicy)
        {
            Argument.EnsureNotNull("connection", connection);
            Argument.EnsureNotNull("mapping", mapping);
            Argument.EnsureNotNull("log", log);
            Argument.EnsureNotNull("retryPolicy", retryPolicy);

            Connection  = connection;
            Mapping     = mapping;
            Log         = log;
            RetryPolicy = retryPolicy;

            requestProcessor = new ElasticRequestProcessor(connection, mapping, log, retryPolicy);
        }
Esempio n. 5
0
 public ElasticSearchContext(ElasticConnection connection, NestElasticLinqMapping mapping = null, ILog log = null, IRetryPolicy retryPolicy = null)
     : base(connection, mapping ?? new NestElasticLinqMapping(), log, retryPolicy)
 {
 }