Пример #1
0
        /// <summary>
        /// Create a new SearchRequestFormatter for the given connection, mapping and search request.
        /// </summary>
        /// <param name="connection">The ElasticConnection to prepare the SearchRequest for.</param>
        /// <param name="mapping">The IElasticMapping used to format the SearchRequest.</param>
        /// <param name="searchRequest">The SearchRequest to be formatted.</param>
        public SearchRequestFormatter(IElasticConnection connection, IElasticMapping mapping, SearchRequest searchRequest)
        {
            this.connection    = connection;
            this.mapping       = mapping;
            this.searchRequest = searchRequest;

            body = new Lazy <string>(() => CreateBody().ToString(connection.Options.Pretty ? Formatting.Indented : Formatting.None));
        }
        /// <summary>
        /// Create a new SearchRequestFormatter for the given connection, mapping and search request.
        /// </summary>
        /// <param name="connection">The ElasticConnection to prepare the SearchRequest for.</param>
        /// <param name="mapping">The IElasticMapping used to format the SearchRequest.</param>
        /// <param name="searchRequest">The SearchRequest to be formatted.</param>
        public SearchRequestFormatter(IElasticConnection connection, IElasticMapping mapping, SearchRequest searchRequest)
        {
            this.connection = connection;
            this.mapping = mapping;
            this.searchRequest = searchRequest;

            body = new Lazy<string>(() => CreateBody().ToString(connection.Options.Pretty ? Formatting.Indented : Formatting.None));
        }
Пример #3
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(IElasticConnection connection, IElasticMapping mapping = null, ILog log = null, IRetryPolicy retryPolicy = null)
        {
            Argument.EnsureNotNull(nameof(connection), connection);

            Connection  = connection;
            Log         = log ?? NullLog.Instance;
            Mapping     = mapping ?? new TrivialElasticMapping(connection, Log);
            RetryPolicy = retryPolicy ?? new RetryPolicy(Log);
        }
        public ElasticRequestProcessor(IElasticConnection connection, IElasticMapping mapping, IRetryPolicy retryPolicy)
        {
            Argument.CheckNotNull("connection", connection);
            Argument.CheckNotNull("mapping", mapping);
            Argument.CheckNotNull("retryPolicy", retryPolicy);

            this.connection  = connection;
            this.mapping     = mapping;
            this.retryPolicy = retryPolicy;
        }
Пример #5
0
            public ElasticSearchTest()
            {
                Connection = new ElasticConnection();
                Connection.InitDb(new Dictionary <Type, string>()
                {
                    { typeof(Student), "unittest-student" }
                }, dbName: "unittest");

                Connection.SetToTestEnv();
            }
        public ElasticRequestProcessor(IElasticConnection connection, IElasticMapping mapping, ILog log, IRetryPolicy retryPolicy)
        {
            Argument.EnsureNotNull("connection", connection);
            Argument.EnsureNotNull("mapping", mapping);
            Argument.EnsureNotNull("log", log);
            Argument.EnsureNotNull("retryPolicy", retryPolicy);

            this.connection = connection;
            this.mapping = mapping;
            this.log = log;
            this.retryPolicy = retryPolicy;
        }
        public VeryElasticQueryProvider(IElasticConnection connection, IElasticMapping mapping, IRetryPolicy retryPolicy)
        {
            Argument.CheckNotNull("connection", connection);
            Argument.CheckNotNull("mapping", mapping);
            Argument.CheckNotNull("retryPolicy", retryPolicy);

            this.Connection  = connection;
            this.Mapping     = mapping;
            this.RetryPolicy = retryPolicy;

            this.requestProcessor = new ElasticRequestProcessor(connection, mapping, retryPolicy);
        }
        public ElasticRequestProcessor(IElasticConnection connection, IElasticMapping mapping, ILog log, IRetryPolicy retryPolicy)
        {
            Argument.EnsureNotNull(nameof(connection), connection);
            Argument.EnsureNotNull(nameof(mapping), mapping);
            Argument.EnsureNotNull(nameof(log), log);
            Argument.EnsureNotNull(nameof(retryPolicy), retryPolicy);

            this.connection  = connection;
            this.mapping     = mapping;
            this.log         = log;
            this.retryPolicy = retryPolicy;
        }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ElasticSession"/> 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="VeryElasticMapping"/>).</param>
 /// <param name="retryPolicy">The object which controls retry policy for the search (optional, defaults to <see cref="RetryPolicy"/>).</param>
 public ElasticSession(IElasticConnection connection, IElasticMapping mapping = null, IRetryPolicy retryPolicy = null)
 {
     this.Connection = connection;
     this.Mapping    = mapping ?? new VeryElasticMapping(
         new JsonSerializerSettings
     {
         DefaultValueHandling = DefaultValueHandling.Ignore,
         NullValueHandling    = NullValueHandling.Ignore,
         ConstructorHandling  = ConstructorHandling.AllowNonPublicDefaultConstructor
     }
         );
     this.RetryPolicy = retryPolicy ?? new RetryPolicy();
 }
Пример #10
0
 public ProcessingBaseCurrentWeatherImpl(IElasticConnection elasticConnection,
                                         ILocationFileReader locationFileReader, IOwmApiReader owmApiReader, IProcessingUtils processingUtils,
                                         IOwmToElasticDocumentConverter <CurrentWeatherBase> owmToElasticDocumentConverter,
                                         IProcessingBaseImplementations processingBaseImplementations)
 {
     _elasticConnection             = elasticConnection;
     _locationFileReader            = locationFileReader;
     _owmApiReader                  = owmApiReader;
     _processingUtils               = processingUtils;
     _owmToElasticDocumentConverter = owmToElasticDocumentConverter;
     _processingBaseImplementations = processingBaseImplementations;
     _logger = Log.Logger.ForContext <ProcessingBaseCurrentWeatherImpl>();
     _logger.Information("Begin with etl process of weather information for locations.");
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ElasticSearchStorage"/> class.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="port">The port.</param>
        public ElasticSearchStorage(string server, int port = 9200)
        {
            // Initialise the LogDelay to be a sensible default if not already set
            if (LogDelay == 0) LogDelay = 60;

            connection = new ElasticConnection(server, port);

            // Subscribe to Log Publishers
            observer = Observable
                .FromEventPattern<Entry>(ev => Log.Entries += ev, ev => Log.Entries -= ev)
                .Select(a => a.EventArgs)
                .Buffer(TimeSpan.FromSeconds(LogDelay))
                .Subscribe(Export);
        }
Пример #12
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(IElasticConnection 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);
        }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ElasticMapping"/> class.
 /// </summary>
 /// <param name="connection">The information on how to connect to the Elasticsearch server.</param>
 /// <param name="log">The object which logs information (optional, defaults to <see cref="NullLog"/>).</param>
 /// <param name="camelCaseFieldNames">Pass <c>true</c> to automatically camel-case field names (for <see cref="GetFieldName(Type, MemberInfo)"/>).</param>
 /// <param name="pluralizeTypeNames">Pass <c>true</c> to automatically pluralize type names (for <see cref="GetIndexType"/>).</param>
 /// <param name="lowerCaseAnalyzedFieldValues">Pass <c>true</c> to automatically convert field values to lower case (for <see cref="FormatValue"/>).</param>
 /// <param name="enumFormat">Pass <c>EnumFormat.String</c> to format enums as strings or <c>EnumFormat.Integer</c> to use integers (defaults to string).</param>
 /// <param name="conversionCulture">The culture to use for the lower-casing, camel-casing, and pluralization operations. If <c>null</c>,
 /// uses <see cref="CultureInfo.CurrentCulture"/>.</param>
 public ElasticMapping(IElasticConnection connection,
                       ILog log,
                       bool camelCaseFieldNames          = true,
                       bool pluralizeTypeNames           = true,
                       bool lowerCaseAnalyzedFieldValues = true,
                       EnumFormat enumFormat             = EnumFormat.String,
                       CultureInfo conversionCulture     = null)
 {
     this._camelCaseFieldNames          = camelCaseFieldNames;
     this._pluralizeTypeNames           = pluralizeTypeNames;
     this._lowerCaseAnalyzedFieldValues = lowerCaseAnalyzedFieldValues;
     this._conversionCulture            = conversionCulture ?? CultureInfo.CurrentCulture;
     this._enumFormat         = enumFormat;
     _elasticPropertyMappings = new Lazy <IDictionary <string, string> >(() =>
     {
         return(connection.GetPropertiesMappings(log).Result);
     });
 }
Пример #14
0
 protected ElasticImporter(IElasticConnection connection)
 {
     _connection = connection;
 }
Пример #15
0
 public EmployeeSupervisor(IElasticConnection elasticConnection, IElasticClient IElasticClient)
 {
     _IElasticConnection = elasticConnection;
     _IElasticClient     = IElasticClient;
 }
Пример #16
0
 public EmployeeSupervisor(IElasticConnection elasticConnection)
 {
     _IElasticConnection = elasticConnection;
 }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TrivialElasticMapping"/> class.
 /// </summary>
 public TrivialElasticMapping(IElasticConnection connection,
                              ILog log) : base(connection, log, false, false, false, EnumFormat.String, null)
 {
 }
Пример #18
0
 public BulkRequestLogImporter(IElasticConnection connection)
     : base(connection)
 {
 }
Пример #19
0
 public BulkRequestLogImporter(IElasticConnection connection) : base(connection)
 {
 }
Пример #20
0
 protected ElasticImporter(IElasticConnection connection)
 {
     _connection = connection;
 }
Пример #21
0
 public ElasticClient(IJsonSerializer serializer, string defaultHost = null, int defaultPort = 9200)
 {
     connection      = new ElasticConnection(defaultHost, defaultPort);
     this.serializer = serializer;
 }
Пример #22
0
 /// <summary>
 /// Gets a query that can search for documents of type <typeparamref name="T" />.
 /// </summary>
 /// <typeparam name="T">document type</typeparam>
 /// <param name="connection">The connection.</param>
 /// <returns>
 /// The query which can used to search documents of the given type.
 /// </returns>
 public IQueryable <T> Query <T>(IElasticConnection connection)
 {
     return(new VeryElasticQuery <T, VeryElasticQueryProvider>(new VeryElasticQueryProvider(connection, this.Mapping, this.RetryPolicy)));
 }