mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-12 07:02:10 +00:00
Default Refresh policy for ReactiveElasticsearchTemplate.
Original Pull Request #2124 Closes #2110 (cherry picked from commit acd7990fac8a07a3816c389849981fd176fd63ab)
This commit is contained in:
parent
a2cee9defd
commit
5549216db0
@ -28,6 +28,14 @@ Connections to Elasticsearch must be made using either the imperative `Elasticse
|
||||
In 4.3 two classes (`ElasticsearchAggregations` and `ElasticsearchAggregation`) had been moved to the `org.springframework.data.elasticsearch.core.clients.elasticsearch7` package in preparation for the integration of the new Elasticsearch client.
|
||||
The were moved back to the `org.springframework.data.elasticsearch.core` package as we keep the classes use the old Elasticsearch client where they were.
|
||||
|
||||
=== Behaviour change
|
||||
|
||||
The `ReactiveElasticsearchTemplate`, when created directly or by Spring Boot configuration had a default refresh policy of IMMEDIATE.
|
||||
This could cause performance issues on heavy indexing and was different than the default behaviour of Elasticsearch.
|
||||
This has been changed to that now the default refresh policy is NONE.
|
||||
When the
|
||||
`ReactiveElasticsearchTemplate` was provided by using the configuration like described in <<elasticsearch.clients.reactive>> the default refresh policy already was set to NONE.
|
||||
|
||||
[[elasticsearch-migration-guide-4.3-4.4.new-clients]]
|
||||
== New Elasticsearch client
|
||||
|
||||
|
@ -73,7 +73,7 @@ abstract public class AbstractReactiveElasticsearchTemplate
|
||||
protected final SimpleElasticsearchMappingContext mappingContext;
|
||||
protected final EntityOperations entityOperations;
|
||||
|
||||
protected @Nullable RefreshPolicy refreshPolicy = RefreshPolicy.IMMEDIATE;
|
||||
protected @Nullable RefreshPolicy refreshPolicy = RefreshPolicy.NONE;
|
||||
protected RoutingResolver routingResolver;
|
||||
|
||||
protected @Nullable ReactiveEntityCallbacks entityCallbacks;
|
||||
|
@ -85,7 +85,7 @@ public class ReactiveElasticsearchTemplateUnitTests {
|
||||
.as(StepVerifier::create) //
|
||||
.verifyComplete();
|
||||
|
||||
assertThat(captor.getValue().getRefreshPolicy()).isEqualTo(WriteRequest.RefreshPolicy.IMMEDIATE);
|
||||
assertThat(captor.getValue().getRefreshPolicy()).isEqualTo(WriteRequest.RefreshPolicy.NONE);
|
||||
}
|
||||
|
||||
@Test // DATAES-504
|
||||
@ -170,7 +170,7 @@ public class ReactiveElasticsearchTemplateUnitTests {
|
||||
.as(StepVerifier::create) //
|
||||
.verifyComplete();
|
||||
|
||||
assertThat(captor.getValue().getRefreshPolicy()).isEqualTo(WriteRequest.RefreshPolicy.IMMEDIATE);
|
||||
assertThat(captor.getValue().getRefreshPolicy()).isEqualTo(WriteRequest.RefreshPolicy.NONE);
|
||||
}
|
||||
|
||||
@Test // DATAES-504
|
||||
@ -198,7 +198,7 @@ public class ReactiveElasticsearchTemplateUnitTests {
|
||||
.as(StepVerifier::create) //
|
||||
.verifyComplete();
|
||||
|
||||
assertThat(captor.getValue().isRefresh()).isTrue();
|
||||
assertThat(captor.getValue().isRefresh()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAES-504
|
||||
@ -207,13 +207,13 @@ public class ReactiveElasticsearchTemplateUnitTests {
|
||||
ArgumentCaptor<DeleteByQueryRequest> captor = ArgumentCaptor.forClass(DeleteByQueryRequest.class);
|
||||
when(client.deleteBy(captor.capture())).thenReturn(Mono.empty());
|
||||
|
||||
template.setRefreshPolicy(RefreshPolicy.NONE);
|
||||
template.setRefreshPolicy(RefreshPolicy.IMMEDIATE);
|
||||
|
||||
template.delete(new StringQuery(QueryBuilders.matchAllQuery().toString()), Object.class, index) //
|
||||
.as(StepVerifier::create) //
|
||||
.verifyComplete();
|
||||
|
||||
assertThat(captor.getValue().isRefresh()).isFalse();
|
||||
assertThat(captor.getValue().isRefresh()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAES-504
|
||||
|
Loading…
x
Reference in New Issue
Block a user