public async Task CanReindexSameIndexAsync() { var index = new EmployeeIndex(_configuration); await index.DeleteAsync(); using (new DisposableAction(() => index.DeleteAsync().GetAwaiter().GetResult())) { await index.ConfigureAsync(); Assert.True((await _client.Indices.ExistsAsync(index.Name)).Exists); IEmployeeRepository repository = new EmployeeRepository(_configuration); var employee = await repository.AddAsync(EmployeeGenerator.Default, o => o.ImmediateConsistency()); Assert.NotNull(employee?.Id); var countResponse = await _client.CountAsync <Employee>(); _logger.LogRequest(countResponse); Assert.True(countResponse.IsValid); Assert.Equal(1, countResponse.Count); var mappingResponse = await _client.Indices.GetMappingAsync <Employee>(); _logger.LogRequest(mappingResponse); Assert.True(mappingResponse.IsValid); Assert.NotNull(mappingResponse.GetMappingFor(index.Name)); var newIndex = new EmployeeIndexWithYearsEmployed(_configuration); await newIndex.ReindexAsync(); countResponse = await _client.CountAsync <Employee>(); _logger.LogRequest(countResponse); Assert.True(countResponse.IsValid); Assert.Equal(1, countResponse.Count); string version1Mappings = ToJson(mappingResponse.GetMappingFor <Employee>()); mappingResponse = await _client.Indices.GetMappingAsync <Employee>(); _logger.LogRequest(mappingResponse); Assert.True(mappingResponse.IsValid); Assert.NotNull(mappingResponse.GetMappingFor <Employee>()); Assert.NotEqual(version1Mappings, ToJson(mappingResponse.GetMappingFor <Employee>())); } }
public async Task CanCreateAndDeleteIndex() { var index = new EmployeeIndex(_configuration); await index.ConfigureAsync(); var existsResponse = await _client.Indices.ExistsAsync(index.Name); _logger.LogRequest(existsResponse); Assert.True(existsResponse.ApiCall.Success); Assert.True(existsResponse.Exists); await index.DeleteAsync(); existsResponse = await _client.Indices.ExistsAsync(index.Name); _logger.LogRequest(existsResponse); Assert.True(existsResponse.ApiCall.Success); Assert.False(existsResponse.Exists); }