Skip to content

Commit d8f43d3

Browse files
DATAES-512 - Polishing.
Update Javadoc and Readme to reflect recent back ports.
1 parent a3a46b2 commit d8f43d3

29 files changed

+114
-40
lines changed

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ the appropriate dependency version.
5454

5555
| spring data elasticsearch | elasticsearch |
5656
|:-------------------------:|:-------------:|
57+
| 3.2.x | 6.5.0 |
5758
| 3.1.x | 6.2.2 |
5859
| 3.0.x | 5.5.0 |
5960
| 2.1.x | 2.4.0 |
@@ -185,6 +186,78 @@ Searching entities using Elasticsearch Template
185186
Page<SampleEntity> sampleEntities = elasticsearchTemplate.queryForPage(searchQuery,SampleEntity.class);
186187
```
187188

189+
### Reactive Elasticsearch
190+
191+
The `ReactiveElasticsearchClient` is a non official driver based on `WebClient`.
192+
It uses the request/response objects provided by the Elasticsearch core project.
193+
194+
```java
195+
@Configuration
196+
public class Config {
197+
198+
@Bean
199+
ReactiveElasticsearchClient client() {
200+
201+
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
202+
.connectedTo("localhost:9200", "localhost:9291")
203+
.build();
204+
205+
return ReactiveRestClients.create(clientConfiguration);
206+
}
207+
}
208+
209+
// ...
210+
211+
Mono<IndexResponse> response = client.index(request ->
212+
213+
request.index("spring-data")
214+
.type("elasticsearch")
215+
.id(randomID())
216+
.source(singletonMap("feature", "reactive-client"))
217+
.setRefreshPolicy(IMMEDIATE)
218+
);
219+
```
220+
221+
The reactive client response, especially for search operations, is bound to the `from` (offset) & `size` (limit) options of the request.
222+
223+
`ReactiveElasticsearchOperations` is the gateway to executing high level commands against an Elasticsearch cluster using the `ReactiveElasticsearchClient`.
224+
The easiest way of setting up the `ReactiveElasticsearchTemplate` is via `AbstractReactiveElasticsearchConfiguration`.
225+
226+
```java
227+
@Configuration
228+
public class Config extends AbstractReactiveElasticsearchConfiguration {
229+
230+
@Bean
231+
@Override
232+
public ReactiveElasticsearchClient reactiveElasticsearchClient() {
233+
// ...
234+
}
235+
}
236+
```
237+
238+
If needed the `ReactiveElasticsearchTemplate` can be configured with default `RefreshPolicy` and `IndicesOptions` that get applied to the related requests by overriding the defaults of `refreshPolicy()` and `indicesOptions()`.
239+
240+
```java
241+
template.save(new Person("Bruce Banner", 42))
242+
.doOnNext(System.out::println)
243+
.flatMap(person -> template.findById(person.id, Person.class))
244+
.doOnNext(System.out::println)
245+
.flatMap(person -> template.delete(person))
246+
.doOnNext(System.out::println)
247+
.flatMap(id -> template.count(Person.class))
248+
.doOnNext(System.out::println)
249+
.subscribe();
250+
```
251+
252+
The above outputs the following sequence on the console.
253+
254+
```bash
255+
> Person(id=QjWCWWcBXiLAnp77ksfR, name=Bruce Banner, age=42)
256+
> Person(id=QjWCWWcBXiLAnp77ksfR, name=Bruce Banner, age=42)
257+
> QjWCWWcBXiLAnp77ksfR
258+
> 0
259+
```
260+
188261
### XML Namespace
189262

190263
You can set up repository scanning via xml configuration, which will happily create your repositories.

src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Configuration interface exposing common client configuration properties for Elasticsearch clients.
3030
*
3131
* @author Mark Paluch
32-
* @since 4.0
32+
* @since 3.2
3333
*/
3434
public interface ClientConfiguration {
3535

src/main/java/org/springframework/data/elasticsearch/client/ClientConfigurationBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* @author Christoph Strobl
3838
* @author Mark Paluch
39-
* @since 4.0
39+
* @since 3.2
4040
*/
4141
class ClientConfigurationBuilder
4242
implements ClientConfigurationBuilderWithRequiredEndpoint, MaybeSecureClientConfigurationBuilder {

src/main/java/org/springframework/data/elasticsearch/client/ClientLogger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*
3030
* @author Mark Paluch
3131
* @author Christoph Strobl
32-
* @since 4.0
32+
* @since 3.2
3333
*/
3434
public abstract class ClientLogger {
3535

src/main/java/org/springframework/data/elasticsearch/client/DefaultClientConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*
3333
* @author Mark Paluch
3434
* @author Christoph Strobl
35-
* @since 4.0
35+
* @since 3.2
3636
*/
3737
class DefaultClientConfiguration implements ClientConfiguration {
3838

src/main/java/org/springframework/data/elasticsearch/client/ElasticsearchHost.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* Value Object containing information about Elasticsearch cluster nodes.
2626
*
2727
* @author Christoph Strobl
28-
* @since 4.0
28+
* @since 3.2
2929
*/
3030
public class ElasticsearchHost {
3131

src/main/java/org/springframework/data/elasticsearch/client/InetSocketAddressParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Utility to parse endpoints in {@code host:port} format into {@link java.net.InetSocketAddress}.
2525
*
2626
* @author Mark Paluch
27-
* @since 4.0
27+
* @since 3.2
2828
*/
2929
class InetSocketAddressParser {
3030

src/main/java/org/springframework/data/elasticsearch/client/NoReachableHostException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* {@link RuntimeException} to be emitted / thrown when the cluster is down (aka none of the known nodes is reachable).
2323
*
2424
* @author Christoph Strobl
25-
* @since 4.0
25+
* @since 3.2
2626
*/
2727
public class NoReachableHostException extends RuntimeException {
2828

src/main/java/org/springframework/data/elasticsearch/client/RestClients.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
*
5353
* @author Christoph Strobl
5454
* @author Mark Paluch
55-
* @since 4.0
55+
* @since 3.2
5656
*/
5757
public final class RestClients {
5858

@@ -157,7 +157,7 @@ default void close() throws IOException {
157157
* Logging interceptors for Elasticsearch client logging.
158158
*
159159
* @see ClientLogger
160-
* @since 4.0
160+
* @since 3.2
161161
*/
162162
private static class HttpLoggingInterceptor implements HttpResponseInterceptor, HttpRequestInterceptor {
163163

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
*
111111
* @author Christoph Strobl
112112
* @author Mark Paluch
113-
* @since 4.0
113+
* @since 3.2
114114
* @see ClientConfiguration
115115
* @see ReactiveRestClients
116116
*/
@@ -657,7 +657,7 @@ public Collection<ElasticsearchHost> hosts() {
657657
* Mutable state object holding scrollId to be used for {@link SearchScrollRequest#scroll(Scroll)}
658658
*
659659
* @author Christoph Strobl
660-
* @since 4.0
660+
* @since 3.2
661661
*/
662662
private static class ScrollState {
663663

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*
3333
* @author Mark Paluch
3434
* @author Christoph Strobl
35-
* @since 4.0
35+
* @since 3.2
3636
*/
3737
class DefaultWebClientProvider implements WebClientProvider {
3838

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*
3333
* @author Christoph Strobl
3434
* @author Mark Paluch
35-
* @since 4.0
35+
* @since 3.2
3636
*/
3737
public interface HostProvider {
3838

@@ -113,7 +113,7 @@ default Mono<WebClient> getActive(Verification verification) {
113113
* {@link Verification} allows to influence the lookup strategy for active hosts.
114114
*
115115
* @author Christoph Strobl
116-
* @since 4.0
116+
* @since 3.2
117117
*/
118118
enum Verification {
119119

@@ -132,7 +132,7 @@ enum Verification {
132132
* Value object accumulating information about an Elasticsearch cluster.
133133
*
134134
* @author Christoph Strobl
135-
* @since 4.0.
135+
* @since 3.2
136136
*/
137137
class ClusterInformation {
138138

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
*
4141
* @author Christoph Strobl
4242
* @author Mark Paluch
43-
* @since 4.0
43+
* @since 3.2
4444
*/
4545
class MultiNodeHostProvider implements HostProvider {
4646

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* Extension to {@link ActionResponse} that also implements {@link ClientResponse}.
3636
*
3737
* @author Christoph Strobl
38-
* @since 4.0
38+
* @since 3.2
3939
*/
4040
class RawActionResponse extends ActionResponse implements ClientResponse {
4141

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
*
5050
* @author Christoph Strobl
5151
* @author Mark Paluch
52-
* @since 4.0
52+
* @since 3.2
5353
* @see ClientConfiguration
5454
* @see ReactiveRestClients
5555
*/
@@ -438,7 +438,7 @@ default Mono<BulkByScrollResponse> deleteBy(DeleteByQueryRequest deleteRequest)
438438
* Low level callback interface operating upon {@link WebClient} to send commands towards elasticsearch.
439439
*
440440
* @author Christoph Strobl
441-
* @since 4.0
441+
* @since 3.2
442442
*/
443443
interface ReactiveElasticsearchClientCallback {
444444
Mono<ClientResponse> doWithClient(WebClient client);
@@ -448,7 +448,7 @@ interface ReactiveElasticsearchClientCallback {
448448
* Cumulative client {@link ElasticsearchHost} information.
449449
*
450450
* @author Christoph Strobl
451-
* @since 4.0
451+
* @since 3.2
452452
*/
453453
interface Status {
454454

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*
2525
* @author Christoph Strobl
2626
* @author Mark Paluch
27-
* @since 4.0
27+
* @since 3.2
2828
*/
2929
public final class ReactiveRestClients {
3030

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
* @author Christoph Strobl
2424
* @author Mark Paluch
25-
* @since 4.0
25+
* @since 3.2
2626
*/
2727
public class RequestBodyEncodingException extends WebClientException {
2828

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*
3131
* @author Christoph Strobl
3232
* @author Mark Paluch
33-
* @since 4.0
33+
* @since 3.2
3434
*/
3535
class SingleNodeHostProvider implements HostProvider {
3636

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
* @author Christoph Strobl
3636
* @author Mark Paluch
37-
* @since 4.0
37+
* @since 3.2
3838
*/
3939
public interface WebClientProvider {
4040

src/main/java/org/springframework/data/elasticsearch/client/util/RequestConverters.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
* </p>
8888
* Modified for usage with {@link ReactiveElasticsearchClient}.
8989
*
90-
* @since 4.0
90+
* @since 3.2
9191
*/
9292
public class RequestConverters {
9393

src/main/java/org/springframework/data/elasticsearch/config/AbstractElasticsearchConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
/**
2424
* @author Christoph Strobl
25-
* @since 4.0
25+
* @since 3.2
2626
* @see ElasticsearchConfigurationSupport
2727
*/
2828
public abstract class AbstractElasticsearchConfiguration extends ElasticsearchConfigurationSupport {

src/main/java/org/springframework/data/elasticsearch/config/AbstractReactiveElasticsearchConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
/**
2828
* @author Christoph Strobl
29-
* @since 4.0
29+
* @since 3.2
3030
* @see ElasticsearchConfigurationSupport
3131
*/
3232
@Configuration

src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
/**
4141
* @author Christoph Strobl
42-
* @since 4.0
42+
* @since 3.2
4343
*/
4444
@Configuration
4545
public class ElasticsearchConfigurationSupport {

src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchExceptionTranslator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
/**
2727
* @author Christoph Strobl
28-
* @since 4.0
28+
* @since 3.2
2929
*/
3030
public class ElasticsearchExceptionTranslator implements PersistenceExceptionTranslator {
3131

0 commit comments

Comments
 (0)