|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2012-2019 the original author or authors. |
|
|
|
|
* Copyright 2012-2020 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -27,15 +27,11 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
@@ -27,15 +27,11 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; |
|
|
|
|
import org.springframework.data.elasticsearch.core.DefaultEntityMapper; |
|
|
|
|
import org.springframework.data.elasticsearch.core.DefaultResultMapper; |
|
|
|
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations; |
|
|
|
|
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; |
|
|
|
|
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate; |
|
|
|
|
import org.springframework.data.elasticsearch.core.EntityMapper; |
|
|
|
|
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations; |
|
|
|
|
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate; |
|
|
|
|
import org.springframework.data.elasticsearch.core.ResultsMapper; |
|
|
|
|
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; |
|
|
|
|
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter; |
|
|
|
|
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext; |
|
|
|
|
@ -48,6 +44,7 @@ import org.springframework.web.reactive.function.client.WebClient;
@@ -48,6 +44,7 @@ import org.springframework.web.reactive.function.client.WebClient;
|
|
|
|
|
* their order of execution. |
|
|
|
|
* |
|
|
|
|
* @author Brian Clozel |
|
|
|
|
* @author Scott Frederick |
|
|
|
|
*/ |
|
|
|
|
abstract class ElasticsearchDataConfiguration { |
|
|
|
|
|
|
|
|
|
@ -66,18 +63,6 @@ abstract class ElasticsearchDataConfiguration {
@@ -66,18 +63,6 @@ abstract class ElasticsearchDataConfiguration {
|
|
|
|
|
return new SimpleElasticsearchMappingContext(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
@ConditionalOnMissingBean |
|
|
|
|
EntityMapper entityMapper(SimpleElasticsearchMappingContext mappingContext) { |
|
|
|
|
return new DefaultEntityMapper(mappingContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
@ConditionalOnMissingBean |
|
|
|
|
ResultsMapper resultsMapper(SimpleElasticsearchMappingContext mappingContext, EntityMapper entityMapper) { |
|
|
|
|
return new DefaultResultMapper(mappingContext, entityMapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
@ -87,9 +72,8 @@ abstract class ElasticsearchDataConfiguration {
@@ -87,9 +72,8 @@ abstract class ElasticsearchDataConfiguration {
|
|
|
|
|
@Bean |
|
|
|
|
@ConditionalOnMissingBean(value = ElasticsearchOperations.class, name = "elasticsearchTemplate") |
|
|
|
|
@ConditionalOnBean(RestHighLevelClient.class) |
|
|
|
|
ElasticsearchRestTemplate elasticsearchTemplate(RestHighLevelClient client, ElasticsearchConverter converter, |
|
|
|
|
ResultsMapper resultsMapper) { |
|
|
|
|
return new ElasticsearchRestTemplate(client, converter, resultsMapper); |
|
|
|
|
ElasticsearchRestTemplate elasticsearchTemplate(RestHighLevelClient client, ElasticsearchConverter converter) { |
|
|
|
|
return new ElasticsearchRestTemplate(client, converter); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -101,10 +85,10 @@ abstract class ElasticsearchDataConfiguration {
@@ -101,10 +85,10 @@ abstract class ElasticsearchDataConfiguration {
|
|
|
|
|
@Bean |
|
|
|
|
@ConditionalOnMissingBean(value = ElasticsearchOperations.class, name = "elasticsearchTemplate") |
|
|
|
|
@ConditionalOnBean(Client.class) |
|
|
|
|
ElasticsearchTemplate elasticsearchTemplate(Client client, ElasticsearchConverter converter, |
|
|
|
|
ResultsMapper resultsMapper) { |
|
|
|
|
@Deprecated |
|
|
|
|
ElasticsearchTemplate elasticsearchTemplate(Client client, ElasticsearchConverter converter) { |
|
|
|
|
try { |
|
|
|
|
return new ElasticsearchTemplate(client, converter, resultsMapper); |
|
|
|
|
return new ElasticsearchTemplate(client, converter); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) { |
|
|
|
|
throw new IllegalStateException(ex); |
|
|
|
|
@ -121,9 +105,8 @@ abstract class ElasticsearchDataConfiguration {
@@ -121,9 +105,8 @@ abstract class ElasticsearchDataConfiguration {
|
|
|
|
|
@ConditionalOnMissingBean(value = ReactiveElasticsearchOperations.class, name = "reactiveElasticsearchTemplate") |
|
|
|
|
@ConditionalOnBean(ReactiveElasticsearchClient.class) |
|
|
|
|
ReactiveElasticsearchTemplate reactiveElasticsearchTemplate(ReactiveElasticsearchClient client, |
|
|
|
|
ElasticsearchConverter converter, ResultsMapper resultsMapper) { |
|
|
|
|
ReactiveElasticsearchTemplate template = new ReactiveElasticsearchTemplate(client, converter, |
|
|
|
|
resultsMapper); |
|
|
|
|
ElasticsearchConverter converter) { |
|
|
|
|
ReactiveElasticsearchTemplate template = new ReactiveElasticsearchTemplate(client, converter); |
|
|
|
|
template.setIndicesOptions(IndicesOptions.strictExpandOpenAndForbidClosed()); |
|
|
|
|
template.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); |
|
|
|
|
return template; |
|
|
|
|
|