public ElasticSearchRepositories(IElasticClientFactory elasticClientFactory, string elasticClientName = null)
 {
     if (elasticClientFactory == null)
     {
         throw new ArgumentNullException(nameof(elasticClientFactory));
     }
     ElasticClient = elasticClientFactory.CreateClient(elasticClientName);
 }
示例#2
0
 public ApprenticeshipSearchClient(IElasticClientFactory elasticClientFactory, string indexName, ILog logger = null)
 {
     _elasticClient             = elasticClientFactory.CreateClient(r => logger?.Debug(r.DebugInformation));
     _indexName                 = indexName;
     _searchFactorConfiguration = GetSearchFactorConfiguration();
     _keywordExcludedTerms      = new[] { "apprenticeships", "apprenticeship", "traineeship", "traineeships", "trainee" };
     _logger = logger;
 }
 public ElasticsearchIndexManager(
     IElasticClientFactory elasticClientFactory,
     IIndexFactory indexFactory
     ) : base(indexFactory)
 {
     // Validate parameters.
     _elasticClient = elasticClientFactory?.CreateClient() ??
                      throw new ArgumentNullException(nameof(elasticClientFactory));
 }
        public IReadOnlyCollection <IIndex> CreateIndices()
        {
            // Create the client.
            IElasticClient client = _elasticElasticClientFactory.CreateClient();

            // Cycle through the sources, create the indexes.
            return(_elasticIndexSources
                   .Select(s => s.CreateIndex(client))
                   .ToReadOnlyCollection());
        }
示例#5
0
 public void Setup()
 {
     _elasticClientFactory = Substitute.For <IElasticClientFactory>();
     _elasticClient        = Substitute.For <IElasticsearchClient>();
     _timer = Substitute.For <IIndexingTimer>();
     _tolerateCallsFactory = Substitute.For <ITolerateCallsFactory>();
     _bulk = Substitute.For <ILogBulkSet>();
     _logEventConverterFactory = Substitute.For <ILogEventConverterFactory>();
     _logEventConverter        = Substitute.For <ILogEventConverter>();
     _elasticFilters           = new ElasticAppenderFilters();
     _fileAccessor             = Substitute.For <IFileAccessor>();
     _eventWriter = Substitute.For <IExternalEventWriter>();
     _elasticClientFactory.CreateClient(null, 0, false, false, null).ReturnsForAnyArgs(_elasticClient);
     _logEventConverterFactory.Create(FixFlags.All, false).ReturnsForAnyArgs(_logEventConverter);
 }
示例#6
0
        public override void ActivateOptions()
        {
            AddOptionalServer();
            _client = _elasticClientFactory.CreateClient(Servers, ElasticSearchTimeout, Ssl, AllowSelfSignedServerCert, AuthenticationMethod);

            _logEventConverter = _logEventConverterFactory.Create(FixedFields, SerializeObjects);

            if (Template != null && Template.IsValid)
            {
                if (IndexAsync)
                {
                    _client.PutTemplateRaw(Template.Name, _fileAccessor.ReadAllText(Template.FileName));
                }
                else
                {
                    _client.PutTemplateRaw(Template.Name, _fileAccessor.ReadAllText(Template.FileName));
                }
            }

            ElasticFilters.PrepareConfiguration(_client);

            _timer.Restart(BulkIdleTimeout);
        }
示例#7
0
 public LocationSearchClient(IElasticClientFactory elasticClientFactory, string indexName)
 {
     _elasticClient = elasticClientFactory.CreateClient();
     _indexName     = indexName;
 }
示例#8
0
 public static ElasticClient CreateClient(this IElasticClientFactory elasticClientFactory)
 {
     return(elasticClientFactory.CreateClient(Microsoft.Extensions.Options.Options.DefaultName));
 }
 public Task Initialise()
 {
     _client = _elasticClientFactory.CreateClient();
     return(Task.FromResult(_client));
 }
示例#10
0
 public TraineeshipSearchClient(IElasticClientFactory elasticClientFactory, string indexName, ILog logger = null)
 {
     _elasticClient = elasticClientFactory.CreateClient(r => logger?.Debug(r.DebugInformation));
     _indexName     = indexName;
     _logger        = logger;
 }