use of org.springframework.data.elasticsearch.core.reindex.ReindexResponse in project spring-data-elasticsearch by spring-projects.
the class ElasticsearchTemplateTests method shouldWorkReindexForExistingIndex.
// #1529
@Test
void shouldWorkReindexForExistingIndex() {
String sourceIndexName = indexNameProvider.indexName();
String documentId = nextIdAsString();
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("abc").build();
operations.save(sampleEntity);
indexNameProvider.increment();
String destIndexName = indexNameProvider.indexName();
operations.indexOps(IndexCoordinates.of(destIndexName)).create();
final ReindexRequest reindexRequest = ReindexRequest.builder(IndexCoordinates.of(sourceIndexName), IndexCoordinates.of(destIndexName)).withRefresh(true).build();
final ReindexResponse reindex = operations.reindex(reindexRequest);
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
assertThat(reindex.getTotal()).isEqualTo(1);
assertThat(operations.count(searchQuery, IndexCoordinates.of(destIndexName))).isEqualTo(1);
}
Aggregations