public async Task RemoveAllWithTimeSeriesAsync()
        {
            var utcNow       = SystemClock.UtcNow;
            var yesterdayLog = LogEventGenerator.Generate(ObjectId.GenerateNewId(utcNow.AddDays(-1)).ToString(), createdUtc: utcNow.AddDays(-1));
            var nowLog       = LogEventGenerator.Default;

            var logs = new List <LogEvent> {
                yesterdayLog, nowLog
            };
            await _dailyRepository.AddAsync(logs, o => o.ImmediateConsistency());

            Assert.Equal(2, await _dailyRepository.CountAsync());

            await _dailyRepository.RemoveAllAsync(o => o.ImmediateConsistency());

            Assert.Equal(0, await _dailyRepository.CountAsync());
        }
        public async Task GetByDateBasedIndexAsync()
        {
            await _configuration.DailyLogEvents.ConfigureAsync();


            // TODO: Fix this once https://github.com/elastic/elasticsearch-net/issues/3829 is fixed in beta2
            //var indexes = await _client.GetIndicesPointingToAliasAsync(_configuration.DailyLogEvents.Name);
            //Assert.Empty(indexes);

            var alias = await _client.Indices.GetAliasAsync(_configuration.DailyLogEvents.Name);

            _logger.LogRequest(alias);
            Assert.False(alias.IsValid);

            var utcNow = SystemClock.UtcNow;
            ILogEventRepository repository = new DailyLogEventRepository(_configuration);
            var logEvent = await repository.AddAsync(LogEventGenerator.Generate(createdUtc: utcNow));

            Assert.NotNull(logEvent?.Id);

            logEvent = await repository.AddAsync(LogEventGenerator.Generate(createdUtc: utcNow.SubtractDays(1)), o => o.ImmediateConsistency());

            Assert.NotNull(logEvent?.Id);

            alias = await _client.Indices.GetAliasAsync(_configuration.DailyLogEvents.Name);

            _logger.LogRequest(alias);
            Assert.True(alias.IsValid);
            Assert.Equal(2, alias.Indices.Count);

            var indexes = await _client.GetIndicesPointingToAliasAsync(_configuration.DailyLogEvents.Name);

            Assert.Equal(2, indexes.Count());

            await repository.RemoveAllAsync(o => o.ImmediateConsistency());

            Assert.Equal(0, await repository.CountAsync());
        }
        public async Task GetByDateBasedIndexAsync()
        {
            await _configuration.DailyLogEvents.ConfigureAsync();

            var indexes = await _client.GetIndicesPointingToAliasAsync(_configuration.DailyLogEvents.Name);

            Assert.Equal(0, indexes.Count());

            var alias = await _client.GetAliasAsync(descriptor => descriptor.Name(_configuration.DailyLogEvents.Name));

            _logger.Trace(() => alias.GetRequest());
            Assert.False(alias.IsValid);

            var utcNow     = SystemClock.UtcNow;
            var repository = new DailyLogEventRepository(_configuration);
            var logEvent   = await repository.AddAsync(LogEventGenerator.Generate(createdUtc: utcNow));

            Assert.NotNull(logEvent?.Id);

            logEvent = await repository.AddAsync(LogEventGenerator.Generate(createdUtc: utcNow.SubtractDays(1)), o => o.ImmediateConsistency());

            Assert.NotNull(logEvent?.Id);

            alias = await _client.GetAliasAsync(descriptor => descriptor.Name(_configuration.DailyLogEvents.Name));

            _logger.Trace(() => alias.GetRequest());
            Assert.True(alias.IsValid);
            Assert.Equal(2, alias.Indices.Count);

            indexes = await _client.GetIndicesPointingToAliasAsync(_configuration.DailyLogEvents.Name);

            Assert.Equal(2, indexes.Count());

            await repository.RemoveAllAsync(o => o.ImmediateConsistency());

            Assert.Equal(0, await repository.CountAsync());
        }