Skip to content

Commit b177dd1

Browse files
authored
DATAES-678 - Introduce ReactiveIndexOperations.
Original PR: spring-projects#481
1 parent aeaa27c commit b177dd1

26 files changed

+1524
-208
lines changed

src/main/asciidoc/reference/elasticsearch-migration-guide-4.0-4.1.adoc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,31 @@
33

44
This section describes breaking changes from version 4.0.x to 4.1.x and how removed features can be replaced by new introduced features.
55

6+
[[elasticsearch-migration-guide-4.0-4.1.deprecations]]
67
== Deprecations
78

89
.Definition of the id property
9-
It is possible to define a property of en entity as the id property by naming it either `id` or `document`. This behaviour is now deprecated and will produce a warning. PLease us the `@Id` annotation to mark a property as being the id property.
10+
It is possible to define a property of en entity as the id property by naming it either `id` or `document`.
11+
This behaviour is now deprecated and will produce a warning.
12+
PLease us the `@Id` annotation to mark a property as being the id property.
13+
14+
In the `ReactiveElasticsearchClient.Indices` interface the `updateMapping` methods are deprecated in favour of the `putMapping` methods.
15+
They do the same, but `putMapping` is consistent with the naming in the Elasticsearch API:
1016

1117
[[elasticsearch-migration-guide-4.0-4.1.removal]]
1218
== Removals
1319

1420
.Type mappings
15-
The _type mappings_ parameters of the `@Document` annotation and the `IndexCoordinates` object were removed. They had been deprecated in Spring Data Elasticsearch 4.0 and their values weren't used anymore.
21+
The _type mappings_ parameters of the `@Document` annotation and the `IndexCoordinates` object were removed.
22+
They had been deprecated in Spring Data Elasticsearch 4.0 and their values weren't used anymore.
23+
24+
[[elasticsearch-migration-guide-4.0-4.1.breaking-changes]]
25+
== Breaking Changes
26+
27+
=== Return types of ReactiveElasticsearchClient.Indices methods
1628

17-
=== Breaking changes
29+
The methods in the `ReactiveElasticsearchClient.Indices` were not used up to now.
30+
With the introduction of the `ReactiveIndexOperations` it became necessary to change some of the return types:
1831

32+
* the `createIndex` variants now return a `Mono<Boolean>` instead of a `Mono<Void>` to signal successful index creation.
33+
* the `updateMapping` variants now return a `Mono<Boolean>` instead of a `Mono<Void>` to signal successful mappings storage.

src/main/java/org/springframework/data/elasticsearch/UncategorizedElasticsearchException.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
*/
2424
public class UncategorizedElasticsearchException extends UncategorizedDataAccessException {
2525

26+
public UncategorizedElasticsearchException(String msg) {
27+
super(msg, null);
28+
}
29+
2630
public UncategorizedElasticsearchException(String msg, Throwable cause) {
2731
super(msg, cause);
2832
}

src/main/java/org/springframework/data/elasticsearch/client/reactive/DefaultReactiveElasticsearchClient.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@
5555
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
5656
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
5757
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
58+
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
59+
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
5860
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
5961
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest;
6062
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
6163
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
64+
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
65+
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
6266
import org.elasticsearch.action.bulk.BulkRequest;
6367
import org.elasticsearch.action.bulk.BulkResponse;
6468
import org.elasticsearch.action.delete.DeleteRequest;
@@ -551,26 +555,20 @@ public Mono<Boolean> existsIndex(HttpHeaders headers, GetIndexRequest request) {
551555
.next();
552556
}
553557

554-
/*
555-
* (non-Javadoc)
556-
* @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices#deleteIndex(org.springframework.http.HttpHeaders, org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)
557-
*/
558558
@Override
559-
public Mono<Void> deleteIndex(HttpHeaders headers, DeleteIndexRequest request) {
559+
public Mono<Boolean> deleteIndex(HttpHeaders headers, DeleteIndexRequest request) {
560560

561561
return sendRequest(request, requestCreator.indexDelete(), AcknowledgedResponse.class, headers) //
562-
.then();
562+
.map(AcknowledgedResponse::isAcknowledged) //
563+
.next();
563564
}
564565

565-
/*
566-
* (non-Javadoc)
567-
* @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices#createIndex(org.springframework.http.HttpHeaders, org.elasticsearch.action.admin.indices.create.CreateIndexRequest)
568-
*/
569566
@Override
570-
public Mono<Void> createIndex(HttpHeaders headers, CreateIndexRequest createIndexRequest) {
567+
public Mono<Boolean> createIndex(HttpHeaders headers, CreateIndexRequest createIndexRequest) {
571568

572569
return sendRequest(createIndexRequest, requestCreator.indexCreate(), AcknowledgedResponse.class, headers) //
573-
.then();
570+
.map(AcknowledgedResponse::isAcknowledged) //
571+
.next();
574572
}
575573

576574
/*
@@ -606,15 +604,12 @@ public Mono<Void> refreshIndex(HttpHeaders headers, RefreshRequest refreshReques
606604
.then();
607605
}
608606

609-
/*
610-
* (non-Javadoc)
611-
* @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices#updateMapping(org.springframework.http.HttpHeaders, org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest)
612-
*/
613607
@Override
614-
public Mono<Void> updateMapping(HttpHeaders headers, PutMappingRequest putMappingRequest) {
608+
public Mono<Boolean> putMapping(HttpHeaders headers, PutMappingRequest putMappingRequest) {
615609

616610
return sendRequest(putMappingRequest, requestCreator.putMapping(), AcknowledgedResponse.class, headers) //
617-
.then();
611+
.map(AcknowledgedResponse::isAcknowledged) //
612+
.next();
618613
}
619614

620615
/*
@@ -628,6 +623,16 @@ public Mono<Void> flushIndex(HttpHeaders headers, FlushRequest flushRequest) {
628623
.then();
629624
}
630625

626+
@Override
627+
public Mono<GetMappingsResponse> getMapping(HttpHeaders headers, GetMappingsRequest getMappingsRequest) {
628+
return sendRequest(getMappingsRequest, requestCreator.getMapping(), GetMappingsResponse.class, headers).next();
629+
}
630+
631+
@Override
632+
public Mono<GetSettingsResponse> getSettings(HttpHeaders headers, GetSettingsRequest getSettingsRequest) {
633+
return sendRequest(getSettingsRequest, requestCreator.getSettings(), GetSettingsResponse.class, headers).next();
634+
}
635+
631636
/*
632637
* (non-Javadoc)
633638
* @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient#ping(org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.ReactiveElasticsearchClientCallback)

0 commit comments

Comments
 (0)