public MyAppElasticConfiguration(IQueue<WorkItemData> workItemQueue, ICacheClient cacheClient, IMessageBus messageBus, ILoggerFactory loggerFactory) : base(workItemQueue, cacheClient, messageBus, loggerFactory) { AddIndex(Identities = new IdentityIndex(this)); AddIndex(Employees = new EmployeeIndex(this)); AddIndex(MonthlyEmployees = new MonthlyEmployeeIndex(this, 1)); AddIndex(DailyLogEvents = new DailyLogEventIndex(this)); AddIndex(MonthlyLogEvents = new MonthlyLogEventIndex(this)); AddIndex(ParentChild = new ParentChildIndex(this)); }
public async Task CanReindexSameIndex() { var index = new EmployeeIndex(_configuration); await index.DeleteAsync(); using (new DisposableAction(() => index.DeleteAsync().GetAwaiter().GetResult())) { await index.ConfigureAsync(); Assert.True(_client.IndexExists(index.Name).Exists); var repository = new EmployeeRepository(index.Employee); var employee = await repository.AddAsync(EmployeeGenerator.Default); await _client.RefreshAsync(); Assert.NotNull(employee?.Id); var countResponse = await _client.CountAsync(d => d.Index(index.Name)); _logger.Trace(() => countResponse.GetRequest()); Assert.True(countResponse.IsValid); Assert.Equal(1, countResponse.Count); var mappingResponse = await _client.GetMappingAsync<Employee>(m => m.Index(index.Name)); _logger.Trace(() => mappingResponse.GetRequest()); Assert.True(mappingResponse.IsValid); Assert.NotNull(mappingResponse.Mappings); var newIndex = new EmployeeIndexWithYearsEmployed(_configuration); await newIndex.ReindexAsync(); countResponse = await _client.CountAsync(d => d.Index(index.Name)); _logger.Trace(() => countResponse.GetRequest()); Assert.True(countResponse.IsValid); Assert.Equal(1, countResponse.Count); string version1Mappings = ToJson(mappingResponse.Mappings); mappingResponse = await _client.GetMappingAsync<Employee>(m => m.Index(index.Name)); _logger.Trace(() => mappingResponse.GetRequest()); Assert.True(mappingResponse.IsValid); Assert.NotNull(mappingResponse.Mappings); Assert.NotEqual(version1Mappings, ToJson(mappingResponse.Mappings)); } }