Skip to content

Default Refresh policy for ReactiveElasticsearchTemplate. #2124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void insertShouldUseDefaultRefreshPolicy() {
.as(StepVerifier::create) //
.verifyComplete();

assertThat(captor.getValue().getRefreshPolicy()).isEqualTo(WriteRequest.RefreshPolicy.IMMEDIATE);
assertThat(captor.getValue().getRefreshPolicy()).isEqualTo(WriteRequest.RefreshPolicy.NONE);
}

@Test // DATAES-504
Expand Down Expand Up @@ -170,7 +170,7 @@ public void deleteShouldUseDefaultRefreshPolicy() {
.as(StepVerifier::create) //
.verifyComplete();

assertThat(captor.getValue().getRefreshPolicy()).isEqualTo(WriteRequest.RefreshPolicy.IMMEDIATE);
assertThat(captor.getValue().getRefreshPolicy()).isEqualTo(WriteRequest.RefreshPolicy.NONE);
}

@Test // DATAES-504
Expand Down Expand Up @@ -198,7 +198,7 @@ public void deleteByShouldUseDefaultRefreshPolicy() {
.as(StepVerifier::create) //
.verifyComplete();

assertThat(captor.getValue().isRefresh()).isTrue();
assertThat(captor.getValue().isRefresh()).isFalse();
}

@Test // DATAES-504
Expand All @@ -207,13 +207,13 @@ public void deleteByShouldApplyRefreshPolicy() {
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
Expand Down