Refactor code using Elasticsearch libs.

Original Pull Request #2196
Closes #2157
This commit is contained in:
Peter-Josef Meisch 2022-06-25 18:29:34 +02:00 committed by GitHub
parent f917fb7a65
commit 1e4b70ba6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
116 changed files with 1715 additions and 328 deletions

View File

@ -37,6 +37,7 @@ built and tested.
[cols="^,^,^,^,^",options="header"] [cols="^,^,^,^,^",options="header"]
|=== |===
| Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework | Spring Boot | Spring Data Release Train | Spring Data Elasticsearch | Elasticsearch | Spring Framework | Spring Boot
| 2022.0 (Turing) | 5.0.x | 8.2.2 | 6.0.x | 3.0.x?
| 2021.2 (Raj) | 4.4.x | 7.17.3 | 5.3.x | 2.7.x | 2021.2 (Raj) | 4.4.x | 7.17.3 | 5.3.x | 2.7.x
| 2021.1 (Q) | 4.3.x | 7.15.2 | 5.3.x | 2.6.x | 2021.1 (Q) | 4.3.x | 7.15.2 | 5.3.x | 2.6.x
| 2021.0 (Pascal) | 4.2.xfootnote:oom[Out of maintenance] | 7.12.0 | 5.3.x | 2.5.x | 2021.0 (Pascal) | 4.2.xfootnote:oom[Out of maintenance] | 7.12.0 | 5.3.x | 2.5.x

View File

@ -0,0 +1,144 @@
[[elasticsearch-migration-guide-4.4-5.0]]
= Upgrading from 4.4.x to 5.0.x
This section describes breaking changes from version 4.4.x to 5.0.x and how removed features can be replaced by new
introduced features.
[[elasticsearch-migration-guide-4.4-4.5.deprecations]]
== Deprecations
=== `org.springframework.data.elasticsearch.client.erhlc` package
See <<elasticsearch-migration-guide-4.4-5.0.breaking-changes-packages>>, all classes in this package have been
deprecated, as the default client implementations to use are the ones based on the new Java Client from
Elasticsearch, se <<elasticsearch-migration-guide-4.4-5.0.new-clients>>
[[elasticsearch-migration-guide-4.4-5.0.breaking-changes]]
== Breaking Changes
=== Removal of deprecated calls
==== suggest calls in operations interfaces have been removed
Both `SearchOperations` and `ReactiveSearchOperations` had deprecated calls that were using Elasticsearch classes as
parameters. These now have been removed and so the dependency on Elasticsearch classes in these APIs has been cleaned.
[[elasticsearch-migration-guide-4.4-5.0.breaking-changes-packages]]
=== Package changes
All the classes that are using or depend on the deprecated Elasticsearch `RestHighLevelClient` have been moved to the
package `org.springframework.data.elasticsearch.client.erhlc`. By this change we now have a clear separation of code
using the old deprecated Elasticsearch libraries, code using the new Elasticsearch client and code that is
independent of the client implementation. Also the reactive implementation that was provided up to now has been moved
here, as this implementation contains code that was copied and adapted from Elasticsearch libraries.
[[elasticsearch-migration-guide-4.4-5.0.new-clients]]
== New Elasticsearch client
Spring Data Elasticsearch now uses the new `ElasticsearchClient` and has
deprecated the use of the previous `RestHighLevelClient`.
=== How to use the new client
In order to use the new client the following steps are necessary:
==== Add dependencies
The dependencies for the new Elasticsearch client are still optional in Spring Data Elasticsearch so they need to be added explicitly:
====
[source,xml]
----
<dependencies>
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>7.17.3</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId> <!-- is Apache 2-->
<version>7.17.3</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
----
====
When using Spring Boot, it is necessary to set the following property in the _pom.xml_.
====
[source,xml]
----
<properties>
<jakarta-json.version>2.0.1</jakarta-json.version>
</properties>
----
====
==== New configuration classes
===== Imperative style
In order configure Spring Data Elasticsearch to use the new client, it is necessary to create a configuration bean that derives from `org.springframework.data.elasticsearch.client.elc.ElasticsearchConfiguration`:
====
[source,java]
----
@Configuration
public class NewRestClientConfig extends ElasticsearchConfiguration {
@Override
public ClientConfiguration clientConfiguration() {
return ClientConfiguration.builder() //
.connectedTo("localhost:9200") //
.build();
}
}
----
====
The configuration is done in the same way as with the old client, but it is not necessary anymore to create more than the configuration bean.
With this configuration, the following beans will be available in the Spring application context:
* a `RestClient` bean, that is the configured low level `RestClient` that is used by the Elasticsearch client
* an `ElasticsearchClient` bean, this is the new client that uses the `RestClient`
* an `ElasticsearchOperations` bean, available with the bean names _elasticsearchOperations_ and _elasticsearchTemplate_, this uses the `ElasticsearchClient`
===== Reactive style
To use the new client in a reactive environment the only difference is the class from which to derive the configuration:
====
[source,java]
----
@Configuration
public class NewRestClientConfig extends ReactiveElasticsearchConfiguration {
@Override
public ClientConfiguration clientConfiguration() {
return ClientConfiguration.builder() //
.connectedTo("localhost:9200") //
.build();
}
}
----
====
With this configuration, the following beans will be available in the Spring application context:
* a `RestClient` bean, that is the configured low level `RestClient` that is used by the Elasticsearch client
* an `ReactiveElasticsearchClient` bean, this is the new reactive client that uses the `RestClient`
* an `ReactiveElasticsearchOperations` bean, available with the bean names _reactiveElasticsearchOperations_ and _reactiveElasticsearchTemplate_, this uses the `ReactiveElasticsearchClient`

View File

@ -1,6 +1,12 @@
[[new-features]] [[new-features]]
= What's new = What's new
[[new-features.5-0-0]]
== New in Spring Data Elasticsearch 5.0
* Upgrade to Java 17 baseline
* Upgrade to Spring Framework 6
[[new-features.4-4-0]] [[new-features.4-4-0]]
== New in Spring Data Elasticsearch 4.4 == New in Spring Data Elasticsearch 4.4

View File

@ -12,4 +12,7 @@ include::elasticsearch-migration-guide-4.1-4.2.adoc[]
include::elasticsearch-migration-guide-4.2-4.3.adoc[] include::elasticsearch-migration-guide-4.2-4.3.adoc[]
include::elasticsearch-migration-guide-4.3-4.4.adoc[] include::elasticsearch-migration-guide-4.3-4.4.adoc[]
include::elasticsearch-migration-guide-4.4-5.0.adoc[]
:leveloffset: -1 :leveloffset: -1

View File

@ -27,7 +27,8 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback; import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback;
import org.springframework.data.elasticsearch.client.reactive.ReactiveRestClients; import org.springframework.data.elasticsearch.client.erhlc.ReactiveRestClients;
import org.springframework.data.elasticsearch.client.erhlc.RestClients;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
@ -68,8 +69,8 @@ public interface ClientConfiguration {
} }
/** /**
* Creates a new {@link ClientConfiguration} instance configured to a single host given {@code hostAndPort}. * Creates a new {@link ClientConfiguration} instance configured to a single host given {@code hostAndPort}. For
* For example given the endpoint http://localhost:9200 * example given the endpoint http://localhost:9200
* *
* <pre class="code"> * <pre class="code">
* ClientConfiguration configuration = ClientConfiguration.create("localhost:9200"); * ClientConfiguration configuration = ClientConfiguration.create("localhost:9200");
@ -82,8 +83,8 @@ public interface ClientConfiguration {
} }
/** /**
* Creates a new {@link ClientConfiguration} instance configured to a single host given {@link InetSocketAddress}. * Creates a new {@link ClientConfiguration} instance configured to a single host given {@link InetSocketAddress}. For
* For example given the endpoint http://localhost:9200 * example given the endpoint http://localhost:9200
* *
* <pre class="code"> * <pre class="code">
* ClientConfiguration configuration = ClientConfiguration * ClientConfiguration configuration = ClientConfiguration

View File

@ -31,7 +31,8 @@ import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback;
import org.springframework.data.elasticsearch.client.ClientConfiguration.ClientConfigurationBuilderWithRequiredEndpoint; import org.springframework.data.elasticsearch.client.ClientConfiguration.ClientConfigurationBuilderWithRequiredEndpoint;
import org.springframework.data.elasticsearch.client.ClientConfiguration.MaybeSecureClientConfigurationBuilder; import org.springframework.data.elasticsearch.client.ClientConfiguration.MaybeSecureClientConfigurationBuilder;
import org.springframework.data.elasticsearch.client.ClientConfiguration.TerminalClientConfigurationBuilder; import org.springframework.data.elasticsearch.client.ClientConfiguration.TerminalClientConfigurationBuilder;
import org.springframework.data.elasticsearch.client.reactive.ReactiveRestClients; import org.springframework.data.elasticsearch.client.erhlc.ReactiveRestClients;
import org.springframework.data.elasticsearch.client.erhlc.RestClients;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;

View File

@ -20,9 +20,11 @@ import jakarta.json.stream.JsonGenerator;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.lang.Nullable;
/** /**
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
@ -41,13 +43,28 @@ final class JsonUtils {
JsonGenerator generator = mapper.jsonProvider().createGenerator(baos); JsonGenerator generator = mapper.jsonProvider().createGenerator(baos);
mapper.serialize(object, generator); mapper.serialize(object, generator);
generator.close(); generator.close();
String jsonMapping = "{}"; String json = "{}";
try { try {
jsonMapping = baos.toString("UTF-8"); json = baos.toString("UTF-8");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
LOGGER.warn("could not read json", e); LOGGER.warn("could not read json", e);
} }
return jsonMapping; return json;
} }
@Nullable
public static String queryToJson(@Nullable co.elastic.clients.elasticsearch._types.query_dsl.Query query, JsonpMapper mapper) {
if (query == null) {
return null;
}
var baos = new ByteArrayOutputStream();
var generator = mapper.jsonProvider().createGenerator(baos);
query.serialize(generator, mapper);
generator.close();
return baos.toString(StandardCharsets.UTF_8);
}
} }

View File

@ -19,8 +19,8 @@ import co.elastic.clients.elasticsearch.cluster.HealthRequest;
import co.elastic.clients.elasticsearch.cluster.HealthResponse; import co.elastic.clients.elasticsearch.cluster.HealthResponse;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveClusterOperations;
import org.springframework.data.elasticsearch.core.cluster.ClusterHealth; import org.springframework.data.elasticsearch.core.cluster.ClusterHealth;
import org.springframework.data.elasticsearch.core.cluster.ReactiveClusterOperations;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
/** /**

View File

@ -39,6 +39,7 @@ import org.springframework.data.elasticsearch.BulkFailureException;
import org.springframework.data.elasticsearch.NoSuchIndexException; import org.springframework.data.elasticsearch.NoSuchIndexException;
import org.springframework.data.elasticsearch.UncategorizedElasticsearchException; import org.springframework.data.elasticsearch.UncategorizedElasticsearchException;
import org.springframework.data.elasticsearch.client.UnsupportedBackendOperation; import org.springframework.data.elasticsearch.client.UnsupportedBackendOperation;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveClusterOperations;
import org.springframework.data.elasticsearch.client.util.ScrollState; import org.springframework.data.elasticsearch.client.util.ScrollState;
import org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate; import org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.AggregationContainer; import org.springframework.data.elasticsearch.core.AggregationContainer;
@ -46,7 +47,6 @@ import org.springframework.data.elasticsearch.core.IndexedObjectInformation;
import org.springframework.data.elasticsearch.core.MultiGetItem; import org.springframework.data.elasticsearch.core.MultiGetItem;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations; import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ReactiveIndexOperations; import org.springframework.data.elasticsearch.core.ReactiveIndexOperations;
import org.springframework.data.elasticsearch.core.cluster.ReactiveClusterOperations;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.document.Document; import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.data.elasticsearch.core.document.SearchDocument; import org.springframework.data.elasticsearch.core.document.SearchDocument;

View File

@ -29,7 +29,6 @@ import java.util.stream.Collectors;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.elasticsearch.search.SearchHits;
import org.springframework.data.elasticsearch.core.TotalHitsRelation; import org.springframework.data.elasticsearch.core.TotalHitsRelation;
import org.springframework.data.elasticsearch.core.document.SearchDocument; import org.springframework.data.elasticsearch.core.document.SearchDocument;
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse; import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse;
@ -76,11 +75,11 @@ class SearchDocumentResponseBuilder {
} }
/** /**
* creates a {@link SearchDocumentResponseBuilder} from {@link SearchHits} with the given scrollId aggregations and * creates a {@link SearchDocumentResponseBuilder} from {@link HitsMetadata} with the given scrollId aggregations and
* suggestES * suggestES
* *
* @param <T> entity type * @param <T> entity type
* @param hitsMetadata the {@link SearchHits} to process * @param hitsMetadata the {@link HitsMetadata} to process
* @param scrollId scrollId * @param scrollId scrollId
* @param aggregations aggregations * @param aggregations aggregations
* @param suggestES the suggestion response from Elasticsearch * @param suggestES the suggestion response from Elasticsearch

View File

@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.config; package org.springframework.data.elasticsearch.client.erhlc;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.data.elasticsearch.config.ElasticsearchConfigurationSupport;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
/** /**
@ -26,7 +26,9 @@ import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverte
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 3.2 * @since 3.2
* @see ElasticsearchConfigurationSupport * @see ElasticsearchConfigurationSupport
* @deprecated since 5.0
*/ */
@Deprecated
public abstract class AbstractElasticsearchConfiguration extends ElasticsearchConfigurationSupport { public abstract class AbstractElasticsearchConfiguration extends ElasticsearchConfigurationSupport {
/** /**

View File

@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.config; package org.springframework.data.elasticsearch.client.erhlc;
import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.IndicesOptions;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.config.ElasticsearchConfigurationSupport;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations; import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.RefreshPolicy; import org.springframework.data.elasticsearch.core.RefreshPolicy;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
@ -29,7 +28,9 @@ import org.springframework.lang.Nullable;
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 3.2 * @since 3.2
* @see ElasticsearchConfigurationSupport * @see ElasticsearchConfigurationSupport
* @deprecated since 5.0
*/ */
@Deprecated
public abstract class AbstractReactiveElasticsearchConfiguration extends ElasticsearchConfigurationSupport { public abstract class AbstractReactiveElasticsearchConfiguration extends ElasticsearchConfigurationSupport {
/** /**

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import static org.springframework.data.elasticsearch.core.query.Criteria.*; import static org.springframework.data.elasticsearch.core.query.Criteria.*;
@ -47,7 +47,9 @@ import org.springframework.util.Assert;
* @author Mohsin Husen * @author Mohsin Husen
* @author Artur Konczak * @author Artur Konczak
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @deprecated since 5.0
*/ */
@Deprecated
class CriteriaFilterProcessor { class CriteriaFilterProcessor {
@Nullable @Nullable

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import static org.elasticsearch.index.query.Operator.*; import static org.elasticsearch.index.query.Operator.*;
import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*;
@ -44,7 +44,9 @@ import org.springframework.util.Assert;
* @author Rasmus Faber-Espensen * @author Rasmus Faber-Espensen
* @author James Bodkin * @author James Bodkin
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @deprecated since 5.0
*/ */
@Deprecated
class CriteriaQueryProcessor { class CriteriaQueryProcessor {
@Nullable @Nullable

View File

@ -13,20 +13,22 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.cluster; package org.springframework.data.elasticsearch.client.erhlc;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RequestOptions;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.cluster.ClusterHealth;
import org.springframework.data.elasticsearch.core.ResponseConverter; import org.springframework.data.elasticsearch.core.cluster.ClusterOperations;
/** /**
* Default implementation of {@link ClusterOperations} using the {@link ElasticsearchRestTemplate}. * Default implementation of {@link ClusterOperations} using the {@link ElasticsearchRestTemplate}.
* *
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 4.2 * @since 4.2
* @deprecated since 5.0
*/ */
@Deprecated
class DefaultClusterOperations implements ClusterOperations { class DefaultClusterOperations implements ClusterOperations {
private final ElasticsearchRestTemplate template; private final ElasticsearchRestTemplate template;

View File

@ -13,20 +13,22 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.cluster; package org.springframework.data.elasticsearch.client.erhlc;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations; import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ResponseConverter; import org.springframework.data.elasticsearch.core.cluster.ClusterHealth;
/** /**
* Default implementation of {@link ReactiveClusterOperations} using the {@link ReactiveElasticsearchOperations}. * Default implementation of {@link ReactiveClusterOperations} using the {@link ReactiveElasticsearchOperations}.
* *
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 4.2 * @since 4.2
* @deprecated since 5.0
*/ */
@Deprecated
public class DefaultReactiveClusterOperations implements ReactiveClusterOperations { public class DefaultReactiveClusterOperations implements ReactiveClusterOperations {
private final ReactiveElasticsearchOperations operations; private final ReactiveElasticsearchOperations operations;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -95,12 +95,10 @@ import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.ClientLogger; import org.springframework.data.elasticsearch.client.ClientLogger;
import org.springframework.data.elasticsearch.client.ElasticsearchHost; import org.springframework.data.elasticsearch.client.ElasticsearchHost;
import org.springframework.data.elasticsearch.client.NoReachableHostException; import org.springframework.data.elasticsearch.client.NoReachableHostException;
import org.springframework.data.elasticsearch.client.reactive.HostProvider.Verification; import org.springframework.data.elasticsearch.client.erhlc.HostProvider.Verification;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Cluster; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient.Cluster;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Indices; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient.Indices;
import org.springframework.data.elasticsearch.client.util.NamedXContents;
import org.springframework.data.elasticsearch.client.util.ScrollState; import org.springframework.data.elasticsearch.client.util.ScrollState;
import org.springframework.data.elasticsearch.core.ResponseConverter;
import org.springframework.data.elasticsearch.core.query.ByQueryResponse; import org.springframework.data.elasticsearch.core.query.ByQueryResponse;
import org.springframework.data.util.Lazy; import org.springframework.data.util.Lazy;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@ -134,7 +132,9 @@ import org.springframework.web.reactive.function.client.WebClient.RequestBodySpe
* @since 3.2 * @since 3.2
* @see ClientConfiguration * @see ClientConfiguration
* @see ReactiveRestClients * @see ReactiveRestClients
* @deprecated since 5.0
*/ */
@Deprecated
public class DefaultReactiveElasticsearchClient implements ReactiveElasticsearchClient, Indices, Cluster { public class DefaultReactiveElasticsearchClient implements ReactiveElasticsearchClient, Indices, Cluster {
private final HostProvider<?> hostProvider; private final HostProvider<?> hostProvider;
@ -893,7 +893,7 @@ public class DefaultReactiveElasticsearchClient implements ReactiveElasticsearch
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient.Status#hosts() * @see org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient.Status#hosts()
*/ */
@Override @Override
public Collection<ElasticsearchHost> hosts() { public Collection<ElasticsearchHost> hosts() {

View File

@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
/** /**
* @author Roman Puchkovskiy * @author Roman Puchkovskiy
* @since 4.0 * @since 4.0
* @deprecated since 5.0
*/ */
@Deprecated
class DefaultRequestCreator implements RequestCreator {} class DefaultRequestCreator implements RequestCreator {}

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Map; import java.util.Map;
@ -37,7 +37,9 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
* @author Huw Ayling-Miller * @author Huw Ayling-Miller
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
class DefaultWebClientProvider implements WebClientProvider { class DefaultWebClientProvider implements WebClientProvider {
private final Map<InetSocketAddress, WebClient> cachedClients; private final Map<InetSocketAddress, WebClient> cachedClients;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.document; package org.springframework.data.elasticsearch.client.erhlc;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -41,7 +41,11 @@ import org.elasticsearch.index.get.GetResult;
import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.SearchHits;
import org.springframework.data.elasticsearch.core.MultiGetItem; import org.springframework.data.elasticsearch.core.MultiGetItem;
import org.springframework.data.elasticsearch.core.ResponseConverter; import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.data.elasticsearch.core.document.Explanation;
import org.springframework.data.elasticsearch.core.document.NestedMetaData;
import org.springframework.data.elasticsearch.core.document.SearchDocument;
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse;
import org.springframework.data.mapping.MappingException; import org.springframework.data.mapping.MappingException;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -62,7 +66,9 @@ import com.fasterxml.jackson.core.JsonGenerator;
* @author Roman Puchkovskiy * @author Roman Puchkovskiy
* @author Matt Gilene * @author Matt Gilene
* @since 4.0 * @since 4.0
* @deprecated since 5.0
*/ */
@Deprecated
public final class DocumentAdapters { public final class DocumentAdapters {
private DocumentAdapters() {} private DocumentAdapters() {}

View File

@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.Aggregation;
import org.springframework.data.elasticsearch.core.AggregationContainer;
import org.springframework.lang.NonNull; import org.springframework.lang.NonNull;
/** /**
@ -23,7 +24,9 @@ import org.springframework.lang.NonNull;
* *
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 4.3 * @since 4.3
* @deprecated since 5.0
*/ */
@Deprecated
public class ElasticsearchAggregation implements AggregationContainer<Aggregation> { public class ElasticsearchAggregation implements AggregationContainer<Aggregation> {
private final Aggregation aggregation; private final Aggregation aggregation;

View File

@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.Aggregations;
import org.springframework.data.elasticsearch.core.AggregationsContainer;
import org.springframework.lang.NonNull; import org.springframework.lang.NonNull;
/** /**
@ -23,7 +24,9 @@ import org.springframework.lang.NonNull;
* *
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 4.3 * @since 4.3
* @deprecated since 5.0
*/ */
@Deprecated
public class ElasticsearchAggregations implements AggregationsContainer<Aggregations> { public class ElasticsearchAggregations implements AggregationsContainer<Aggregations> {
private final Aggregations aggregations; private final Aggregations aggregations;

View File

@ -13,15 +13,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.cluster; package org.springframework.data.elasticsearch.client.erhlc;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.cluster.ClusterOperations;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 4.4 * @since 4.4
* @deprecated since 5.0
*/ */
@Deprecated
public class ElasticsearchClusterOperations { public class ElasticsearchClusterOperations {
/** /**
* Creates a ClusterOperations for a {@link ElasticsearchRestTemplate}. * Creates a ClusterOperations for a {@link ElasticsearchRestTemplate}.

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -44,7 +44,9 @@ import org.springframework.util.StringUtils;
* @author Roman Puchkovskiy * @author Roman Puchkovskiy
* @author Mark Paluch * @author Mark Paluch
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
public class ElasticsearchExceptionTranslator implements PersistenceExceptionTranslator { public class ElasticsearchExceptionTranslator implements PersistenceExceptionTranslator {
@Override @Override

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -57,17 +57,20 @@ import org.elasticsearch.index.reindex.UpdateByQueryRequest;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.elasticsearch.search.suggest.SuggestBuilder; import org.elasticsearch.search.suggest.SuggestBuilder;
import org.springframework.data.elasticsearch.BulkFailureException; import org.springframework.data.elasticsearch.BulkFailureException;
import org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.IndexOperations;
import org.springframework.data.elasticsearch.core.IndexedObjectInformation;
import org.springframework.data.elasticsearch.core.MultiGetItem;
import org.springframework.data.elasticsearch.core.RefreshPolicy;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.SearchScrollHits;
import org.springframework.data.elasticsearch.core.cluster.ClusterOperations; import org.springframework.data.elasticsearch.core.cluster.ClusterOperations;
import org.springframework.data.elasticsearch.core.cluster.ElasticsearchClusterOperations;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.document.DocumentAdapters;
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponseBuilder;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.BulkOptions; import org.springframework.data.elasticsearch.core.query.BulkOptions;
import org.springframework.data.elasticsearch.core.query.ByQueryResponse; import org.springframework.data.elasticsearch.core.query.ByQueryResponse;
import org.springframework.data.elasticsearch.core.query.IndexQuery; import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery; import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.UpdateQuery; import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.core.query.UpdateResponse; import org.springframework.data.elasticsearch.core.query.UpdateResponse;
@ -110,7 +113,9 @@ import org.springframework.util.Assert;
* @author Farid Faoudi * @author Farid Faoudi
* @author Sijia Liu * @author Sijia Liu
* @since 4.4 * @since 4.4
* @deprecated since 5.0
*/ */
@Deprecated
public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate { public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate {
private static final Log LOGGER = LogFactory.getLog(ElasticsearchRestTemplate.class); private static final Log LOGGER = LogFactory.getLog(ElasticsearchRestTemplate.class);

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.query; package org.springframework.data.elasticsearch.client.erhlc;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -35,7 +35,9 @@ import org.springframework.util.StringUtils;
* Converts the {@link Highlight} annotation from a method to an Elasticsearch 7 {@link HighlightBuilder}. * Converts the {@link Highlight} annotation from a method to an Elasticsearch 7 {@link HighlightBuilder}.
* *
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @deprecated since 5.0
*/ */
@Deprecated
public class HighlightQueryBuilder { public class HighlightQueryBuilder {
private final MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext; private final MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -36,7 +36,9 @@ import org.springframework.web.reactive.function.client.WebClient;
* @author Mark Paluch * @author Mark Paluch
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
public interface HostProvider<T extends HostProvider<T>> { public interface HostProvider<T extends HostProvider<T>> {
/** /**

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -45,7 +45,9 @@ import org.springframework.web.reactive.function.client.WebClient;
* @author Mark Paluch * @author Mark Paluch
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> { class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> {
private final static Log LOGGER = LogFactory.getLog(MultiNodeHostProvider.class); private final static Log LOGGER = LogFactory.getLog(MultiNodeHostProvider.class);
@ -68,7 +70,7 @@ class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.elasticsearch.client.reactive.HostProvider#clusterInfo() * @see org.springframework.data.elasticsearch.client.erhlc.HostProvider#clusterInfo()
*/ */
@Override @Override
public Mono<ClusterInformation> clusterInfo() { public Mono<ClusterInformation> clusterInfo() {
@ -78,7 +80,7 @@ class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.elasticsearch.client.reactive.HostProvider#createWebClient(java.net.InetSocketAddress) * @see org.springframework.data.elasticsearch.client.erhlc.HostProvider#createWebClient(java.net.InetSocketAddress)
*/ */
@Override @Override
public WebClient createWebClient(InetSocketAddress endpoint) { public WebClient createWebClient(InetSocketAddress endpoint) {
@ -87,7 +89,7 @@ class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.elasticsearch.client.reactive.HostProvider#lookupActiveHost(org.springframework.data.elasticsearch.client.reactive.HostProvider.Verification) * @see org.springframework.data.elasticsearch.client.erhlc.HostProvider#lookupActiveHost(org.springframework.data.elasticsearch.client.erhlc.HostProvider.Verification)
*/ */
@Override @Override
public Mono<InetSocketAddress> lookupActiveHost(Verification verification) { public Mono<InetSocketAddress> lookupActiveHost(Verification verification) {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.util; package org.springframework.data.elasticsearch.client.erhlc;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -78,7 +78,6 @@ import org.elasticsearch.search.suggest.term.TermSuggestionBuilder;
import org.elasticsearch.xcontent.ContextParser; import org.elasticsearch.xcontent.ContextParser;
import org.elasticsearch.xcontent.NamedXContentRegistry; import org.elasticsearch.xcontent.NamedXContentRegistry;
import org.elasticsearch.xcontent.ParseField; import org.elasticsearch.xcontent.ParseField;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
/** /**
* <p> * <p>
@ -92,7 +91,9 @@ import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsea
* *
* @author Russell Parry * @author Russell Parry
* @since 4.0 * @since 4.0
* @deprecated since 5.0
*/ */
@Deprecated
public class NamedXContents { public class NamedXContents {
private NamedXContents() { private NamedXContents() {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.query; package org.springframework.data.elasticsearch.client.erhlc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -28,6 +28,8 @@ import org.elasticsearch.search.collapse.CollapseBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.SortBuilder; import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.suggest.SuggestBuilder; import org.elasticsearch.search.suggest.SuggestBuilder;
import org.springframework.data.elasticsearch.core.query.BaseQuery;
import org.springframework.data.elasticsearch.core.query.IndexBoost;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -43,7 +45,9 @@ import org.springframework.lang.Nullable;
* @author Martin Choraine * @author Martin Choraine
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @author Sijia Liu * @author Sijia Liu
* @deprecated since 5.0
*/ */
@Deprecated
public class NativeSearchQuery extends BaseQuery { public class NativeSearchQuery extends BaseQuery {
@Nullable private final QueryBuilder query; @Nullable private final QueryBuilder query;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.query; package org.springframework.data.elasticsearch.client.erhlc;
import static org.springframework.util.CollectionUtils.*; import static org.springframework.util.CollectionUtils.*;
@ -32,6 +32,10 @@ import org.elasticsearch.search.collapse.CollapseBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.SortBuilder; import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.suggest.SuggestBuilder; import org.elasticsearch.search.suggest.SuggestBuilder;
import org.springframework.data.elasticsearch.core.query.BaseQueryBuilder;
import org.springframework.data.elasticsearch.core.query.IndicesOptions;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.RescorerQuery;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -50,7 +54,9 @@ import org.springframework.lang.Nullable;
* @author Peer Mueller * @author Peer Mueller
* @author vdisk * @author vdisk
* @author owen.qq * @author owen.qq
* @deprecated since 5.0
*/ */
@Deprecated
public class NativeSearchQueryBuilder extends BaseQueryBuilder<NativeSearchQuery, NativeSearchQueryBuilder> { public class NativeSearchQueryBuilder extends BaseQueryBuilder<NativeSearchQuery, NativeSearchQueryBuilder> {
@Nullable private QueryBuilder queryBuilder; @Nullable private QueryBuilder queryBuilder;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -34,7 +34,9 @@ import org.springframework.web.reactive.function.client.ClientResponse;
* @author Mark Paluch * @author Mark Paluch
* @author Oliver Drotbohm * @author Oliver Drotbohm
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
class RawActionResponse extends ActionResponse { class RawActionResponse extends ActionResponse {
private final ClientResponse delegate; private final ClientResponse delegate;

View File

@ -13,16 +13,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.cluster; package org.springframework.data.elasticsearch.client.erhlc;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import org.springframework.data.elasticsearch.core.cluster.ClusterHealth;
/** /**
* Reactive Elasticsearch operations on cluster level. * Reactive Elasticsearch operations on cluster level.
* *
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 4.2 * @since 4.2
* @deprecated since 5.0
*/ */
@Deprecated
public interface ReactiveClusterOperations { public interface ReactiveClusterOperations {
/** /**

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -47,18 +47,21 @@ import org.reactivestreams.Publisher;
import org.springframework.data.elasticsearch.BulkFailureException; import org.springframework.data.elasticsearch.BulkFailureException;
import org.springframework.data.elasticsearch.NoSuchIndexException; import org.springframework.data.elasticsearch.NoSuchIndexException;
import org.springframework.data.elasticsearch.UncategorizedElasticsearchException; import org.springframework.data.elasticsearch.UncategorizedElasticsearchException;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.core.AbstractReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.cluster.DefaultReactiveClusterOperations; import org.springframework.data.elasticsearch.core.AggregationContainer;
import org.springframework.data.elasticsearch.core.cluster.ReactiveClusterOperations; import org.springframework.data.elasticsearch.core.IndexedObjectInformation;
import org.springframework.data.elasticsearch.core.MultiGetItem;
import org.springframework.data.elasticsearch.core.ReactiveIndexOperations;
import org.springframework.data.elasticsearch.core.RefreshPolicy;
import org.springframework.data.elasticsearch.core.SearchHitMapping;
import org.springframework.data.elasticsearch.core.SearchHitSupport;
import org.springframework.data.elasticsearch.core.SearchPage;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.document.DocumentAdapters;
import org.springframework.data.elasticsearch.core.document.SearchDocument; import org.springframework.data.elasticsearch.core.document.SearchDocument;
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse; import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse;
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponseBuilder;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.BulkOptions; import org.springframework.data.elasticsearch.core.query.BulkOptions;
import org.springframework.data.elasticsearch.core.query.ByQueryResponse; import org.springframework.data.elasticsearch.core.query.ByQueryResponse;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.UpdateQuery; import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.core.query.UpdateResponse; import org.springframework.data.elasticsearch.core.query.UpdateResponse;
@ -82,7 +85,9 @@ import org.springframework.util.Assert;
* @author Farid Faoudi * @author Farid Faoudi
* @author Sijia Liu * @author Sijia Liu
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
public class ReactiveElasticsearchTemplate extends AbstractReactiveElasticsearchTemplate { public class ReactiveElasticsearchTemplate extends AbstractReactiveElasticsearchTemplate {
private final ReactiveElasticsearchClient client; private final ReactiveElasticsearchClient client;

View File

@ -13,11 +13,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import static org.elasticsearch.client.Requests.*; import static org.elasticsearch.client.Requests.*;
import static org.springframework.util.StringUtils.*; import static org.springframework.util.StringUtils.*;
import org.springframework.data.elasticsearch.core.IndexInformation;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ReactiveIndexOperations;
import org.springframework.data.elasticsearch.core.ReactiveResourceUtil;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -62,7 +66,9 @@ import org.springframework.util.Assert;
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @author George Popides * @author George Popides
* @since 4.1 * @since 4.1
* @deprecated since 5.0
*/ */
@Deprecated
class ReactiveIndexTemplate implements ReactiveIndexOperations { class ReactiveIndexTemplate implements ReactiveIndexOperations {
private static final Log LOGGER = LogFactory.getLog(ReactiveIndexTemplate.class); private static final Log LOGGER = LogFactory.getLog(ReactiveIndexTemplate.class);

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import java.util.function.Function; import java.util.function.Function;
@ -29,7 +29,9 @@ import org.springframework.web.reactive.function.client.WebClient;
* @author Mark Paluch * @author Mark Paluch
* @author Roman Puchkovskiy * @author Roman Puchkovskiy
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
public final class ReactiveRestClients { public final class ReactiveRestClients {
private ReactiveRestClients() {} private ReactiveRestClients() {}

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import org.springframework.web.reactive.function.client.WebClientException; import org.springframework.web.reactive.function.client.WebClientException;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.util; package org.springframework.data.elasticsearch.client.erhlc;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -101,7 +101,6 @@ import org.elasticsearch.xcontent.XContent;
import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentParser; import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xcontent.XContentType; import org.elasticsearch.xcontent.XContentType;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
@ -120,7 +119,9 @@ import org.springframework.lang.Nullable;
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @author Farid Faoudi * @author Farid Faoudi
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
@SuppressWarnings("JavadocReference") @SuppressWarnings("JavadocReference")
public class RequestConverters { public class RequestConverters {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import java.io.IOException; import java.io.IOException;
import java.util.function.Function; import java.util.function.Function;
@ -53,14 +53,15 @@ import org.elasticsearch.index.reindex.ReindexRequest;
import org.elasticsearch.index.reindex.UpdateByQueryRequest; import org.elasticsearch.index.reindex.UpdateByQueryRequest;
import org.elasticsearch.script.mustache.SearchTemplateRequest; import org.elasticsearch.script.mustache.SearchTemplateRequest;
import org.springframework.data.elasticsearch.UncategorizedElasticsearchException; import org.springframework.data.elasticsearch.UncategorizedElasticsearchException;
import org.springframework.data.elasticsearch.client.util.RequestConverters;
/** /**
* @author Roman Puchkovskiy * @author Roman Puchkovskiy
* @author Farid Faoudi * @author Farid Faoudi
* @author George Popides * @author George Popides
* @since 4.0 * @since 4.0
* @deprecated since 5.0
*/ */
@Deprecated
public interface RequestCreator { public interface RequestCreator {
default Function<SearchRequest, Request> search() { default Function<SearchRequest, Request> search() {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import static org.elasticsearch.core.TimeValue.*; import static org.elasticsearch.core.TimeValue.*;
import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*;
@ -91,6 +91,8 @@ import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentBuilder;
import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.RefreshPolicy;
import org.springframework.data.elasticsearch.core.ScriptType;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.document.Document; import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.data.elasticsearch.core.index.AliasAction; import org.springframework.data.elasticsearch.core.index.AliasAction;
@ -127,7 +129,9 @@ import org.springframework.util.StringUtils;
* @author Sijia Liu * @author Sijia Liu
* @author Peter Nowak * @author Peter Nowak
* @since 4.0 * @since 4.0
* @deprecated since 5.0
*/ */
@Deprecated
class RequestFactory { class RequestFactory {
// the default max result window size of Elasticsearch // the default max result window size of Elasticsearch

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -40,6 +40,8 @@ import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.index.reindex.BulkByScrollResponse; import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.elasticsearch.index.reindex.ScrollableHitSource; import org.elasticsearch.index.reindex.ScrollableHitSource;
import org.springframework.data.elasticsearch.core.IndexInformation;
import org.springframework.data.elasticsearch.core.MultiGetItem;
import org.springframework.data.elasticsearch.core.cluster.ClusterHealth; import org.springframework.data.elasticsearch.core.cluster.ClusterHealth;
import org.springframework.data.elasticsearch.core.document.Document; import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.data.elasticsearch.core.index.AliasData; import org.springframework.data.elasticsearch.core.index.AliasData;
@ -57,7 +59,9 @@ import org.springframework.util.Assert;
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @author Sijia Liu * @author Sijia Liu
* @since 4.2 * @since 4.2
* @deprecated since 5.0
*/ */
@Deprecated
public class ResponseConverter { public class ResponseConverter {
private ResponseConverter() {} private ResponseConverter() {}

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client; package org.springframework.data.elasticsearch.client.erhlc;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
@ -35,7 +35,9 @@ import org.springframework.util.Assert;
* *
* @author Don Wellington * @author Don Wellington
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @deprecated since 5.0
*/ */
@Deprecated
public class RestClientFactoryBean implements FactoryBean<RestHighLevelClient>, InitializingBean, DisposableBean { public class RestClientFactoryBean implements FactoryBean<RestHighLevelClient>, InitializingBean, DisposableBean {
private static final Log LOGGER = LogFactory.getLog(RestClientFactoryBean.class); private static final Log LOGGER = LogFactory.getLog(RestClientFactoryBean.class);

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client; package org.springframework.data.elasticsearch.client.erhlc;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.Closeable; import java.io.Closeable;
@ -44,6 +44,8 @@ import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.RestHighLevelClientBuilder; import org.elasticsearch.client.RestHighLevelClientBuilder;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.ClientLogger;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -59,7 +61,9 @@ import org.springframework.util.Assert;
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @author Nic Hines * @author Nic Hines
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
public final class RestClients { public final class RestClients {
/** /**

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -40,6 +40,9 @@ import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
import org.elasticsearch.client.indices.PutIndexTemplateRequest; import org.elasticsearch.client.indices.PutIndexTemplateRequest;
import org.elasticsearch.client.indices.PutMappingRequest; import org.elasticsearch.client.indices.PutMappingRequest;
import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.springframework.data.elasticsearch.core.AbstractIndexTemplate;
import org.springframework.data.elasticsearch.core.IndexInformation;
import org.springframework.data.elasticsearch.core.IndexOperations;
import org.springframework.data.elasticsearch.core.document.Document; import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.data.elasticsearch.core.index.AliasActions; import org.springframework.data.elasticsearch.core.index.AliasActions;
import org.springframework.data.elasticsearch.core.index.AliasData; import org.springframework.data.elasticsearch.core.index.AliasData;
@ -60,7 +63,9 @@ import org.springframework.util.Assert;
* @author Sascha Woo * @author Sascha Woo
* @author George Popides * @author George Popides
* @since 4.0 * @since 4.0
* @deprecated since 5.0
*/ */
@Deprecated
class RestIndexTemplate extends AbstractIndexTemplate implements IndexOperations { class RestIndexTemplate extends AbstractIndexTemplate implements IndexOperations {
private static final Log LOGGER = LogFactory.getLog(RestIndexTemplate.class); private static final Log LOGGER = LogFactory.getLog(RestIndexTemplate.class);

View File

@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.query; package org.springframework.data.elasticsearch.client.erhlc;
import org.elasticsearch.script.Script; import org.elasticsearch.script.Script;
/** /**
* @author Ryan Murfitt * @author Ryan Murfitt
* @author Artur Konczak * @author Artur Konczak
* @deprecated since 5.0
*/ */
@Deprecated
public class ScriptField { public class ScriptField {
private final String fieldName; private final String fieldName;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core.document; package org.springframework.data.elasticsearch.client.erhlc;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -26,7 +26,8 @@ import org.elasticsearch.common.text.Text;
import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.Aggregations;
import org.springframework.data.elasticsearch.core.ElasticsearchAggregations; import org.springframework.data.elasticsearch.core.document.SearchDocument;
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse;
import org.springframework.data.elasticsearch.core.suggest.response.CompletionSuggestion; import org.springframework.data.elasticsearch.core.suggest.response.CompletionSuggestion;
import org.springframework.data.elasticsearch.core.suggest.response.PhraseSuggestion; import org.springframework.data.elasticsearch.core.suggest.response.PhraseSuggestion;
import org.springframework.data.elasticsearch.core.suggest.response.SortBy; import org.springframework.data.elasticsearch.core.suggest.response.SortBy;
@ -41,7 +42,9 @@ import org.springframework.util.Assert;
* *
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 4.0 * @since 4.0
* @deprecated since 5.0
*/ */
@Deprecated
public class SearchDocumentResponseBuilder { public class SearchDocumentResponseBuilder {
private static final Log LOGGER = LogFactory.getLog(SearchDocumentResponse.class); private static final Log LOGGER = LogFactory.getLog(SearchDocumentResponse.class);

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.SearchHits;
@ -22,7 +22,9 @@ import org.elasticsearch.search.SearchHits;
* *
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 4.4 * @since 4.4
* @deprecated since 5.0
*/ */
@Deprecated
public final class SearchHitsUtil { public final class SearchHitsUtil {
private SearchHitsUtil() {} private SearchHitsUtil() {}

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -32,7 +32,9 @@ import org.springframework.web.reactive.function.client.WebClient;
* @author Mark Paluch * @author Mark Paluch
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
class SingleNodeHostProvider implements HostProvider<SingleNodeHostProvider> { class SingleNodeHostProvider implements HostProvider<SingleNodeHostProvider> {
private final WebClientProvider clientProvider; private final WebClientProvider clientProvider;
@ -48,7 +50,7 @@ class SingleNodeHostProvider implements HostProvider<SingleNodeHostProvider> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.elasticsearch.client.reactive.HostProvider#clusterInfo() * @see org.springframework.data.elasticsearch.client.erhlc.HostProvider#clusterInfo()
*/ */
@Override @Override
public Mono<ClusterInformation> clusterInfo() { public Mono<ClusterInformation> clusterInfo() {
@ -71,7 +73,7 @@ class SingleNodeHostProvider implements HostProvider<SingleNodeHostProvider> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.elasticsearch.client.reactive.HostProvider#createWebClient(java.net.InetSocketAddress) * @see org.springframework.data.elasticsearch.client.erhlc.HostProvider#createWebClient(java.net.InetSocketAddress)
*/ */
@Override @Override
public WebClient createWebClient(InetSocketAddress endpoint) { public WebClient createWebClient(InetSocketAddress endpoint) {
@ -80,7 +82,7 @@ class SingleNodeHostProvider implements HostProvider<SingleNodeHostProvider> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.elasticsearch.client.reactive.HostProvider#lookupActiveHost(org.springframework.data.elasticsearch.client.reactive.HostProvider.Verification) * @see org.springframework.data.elasticsearch.client.erhlc.HostProvider#lookupActiveHost(org.springframework.data.elasticsearch.client.erhlc.HostProvider.Verification)
*/ */
@Override @Override
public Mono<InetSocketAddress> lookupActiveHost(Verification verification) { public Mono<InetSocketAddress> lookupActiveHost(Verification verification) {

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import io.netty.channel.ChannelOption; import io.netty.channel.ChannelOption;
import io.netty.handler.ssl.ApplicationProtocolConfig; import io.netty.handler.ssl.ApplicationProtocolConfig;
@ -55,7 +55,9 @@ import org.springframework.web.reactive.function.client.WebClient;
* @author Huw Ayling-Miller * @author Huw Ayling-Miller
* @author Peter-Josef Meisch * @author Peter-Josef Meisch
* @since 3.2 * @since 3.2
* @deprecated since 5.0
*/ */
@Deprecated
public interface WebClientProvider { public interface WebClientProvider {
/** /**

View File

@ -0,0 +1,25 @@
/*
* Copyright 2022 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This package contains classes that use the old Elasticsearch 7 libraries to access Elasticsearch either directly by
* using the RestHighLevelClient or indirectly by using code copied from Elasticsearch libraries (reactive
* implementation). These classes are deprectaed in favour of using the implementations using the new Elasticsearch
* Client.
*/
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
package org.springframework.data.elasticsearch.client.erhlc;

View File

@ -1,3 +0,0 @@
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
package org.springframework.data.elasticsearch.client.reactive;

View File

@ -27,6 +27,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.Converter;
import org.springframework.core.type.filter.AnnotationTypeFilter; import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.client.erhlc.AbstractReactiveElasticsearchConfiguration;
import org.springframework.data.elasticsearch.core.RefreshPolicy; import org.springframework.data.elasticsearch.core.RefreshPolicy;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchCustomConversions; import org.springframework.data.elasticsearch.core.convert.ElasticsearchCustomConversions;

View File

@ -19,7 +19,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser; import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.data.elasticsearch.client.RestClientFactoryBean; import org.springframework.data.elasticsearch.client.erhlc.RestClientFactoryBean;
import org.w3c.dom.Element; import org.w3c.dom.Element;
/** /**

View File

@ -16,8 +16,9 @@
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.core;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.client.erhlc.ReactiveClusterOperations;
import org.springframework.data.elasticsearch.core.cluster.ReactiveClusterOperations; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity; import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;

View File

@ -21,8 +21,8 @@ import reactor.core.publisher.Mono;
import java.util.List; import java.util.List;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.suggest.response.Suggest; import org.springframework.data.elasticsearch.core.suggest.response.Suggest;

View File

@ -32,7 +32,6 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import org.springframework.data.elasticsearch.annotations.*; import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.ResourceUtil; import org.springframework.data.elasticsearch.core.ResourceUtil;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchTypeMapper; import org.springframework.data.elasticsearch.core.convert.ElasticsearchTypeMapper;

View File

@ -28,6 +28,7 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate; import org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.IndexOperations; import org.springframework.data.elasticsearch.core.IndexOperations;
@ -41,7 +42,6 @@ import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersiste
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.BaseQuery; import org.springframework.data.elasticsearch.core.query.BaseQuery;
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery; import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.data.util.StreamUtils; import org.springframework.data.util.StreamUtils;

View File

@ -21,8 +21,8 @@ import reactor.core.publisher.Mono;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate; import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.MultiGetItem; import org.springframework.data.elasticsearch.core.MultiGetItem;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations; import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ReactiveIndexOperations; import org.springframework.data.elasticsearch.core.ReactiveIndexOperations;

View File

@ -1,60 +0,0 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.plugins;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.List;
/**
* A classloader that is a union over the parent core classloader and classloaders of extended plugins. Cloned from ES
* repository - that file is only available in ES server libs - and we need it o create a node client for unittests
*/
public class ExtendedPluginsClassLoader extends ClassLoader {
/** Loaders of plugins extended by a plugin. */
private final List<ClassLoader> extendedLoaders;
private ExtendedPluginsClassLoader(ClassLoader parent, List<ClassLoader> extendedLoaders) {
super(parent);
this.extendedLoaders = Collections.unmodifiableList(extendedLoaders);
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
for (ClassLoader loader : extendedLoaders) {
try {
return loader.loadClass(name);
} catch (ClassNotFoundException e) {
// continue
}
}
throw new ClassNotFoundException(name);
}
/**
* Return a new classloader across the parent and extended loaders.
*/
public static ExtendedPluginsClassLoader create(ClassLoader parent, List<ClassLoader> extendedLoaders) {
return AccessController.doPrivileged(
(PrivilegedAction<ExtendedPluginsClassLoader>) () -> new ExtendedPluginsClassLoader(parent, extendedLoaders));
}
}

View File

@ -21,7 +21,7 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;

View File

@ -0,0 +1,107 @@
/*
* Copyright 2022 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.elasticsearch;
import static co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders.*;
import static org.springframework.data.elasticsearch.client.elc.QueryBuilders.*;
import co.elastic.clients.elasticsearch._types.query_dsl.ChildScoreMode;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.client.elc.NativeQuery;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
import org.springframework.data.elasticsearch.utils.IndexNameProvider;
import org.springframework.test.context.ContextConfiguration;
/**
* @author Peter-Josef Meisch
*/
@ContextConfiguration(classes = { NestedObjectELCIntegrationTests.Config.class })
public class NestedObjectELCIntegrationTests extends NestedObjectIntegrationTests {
@Configuration
@Import({ ElasticsearchTemplateConfiguration.class })
static class Config {
@Bean
IndexNameProvider indexNameProvider() {
return new IndexNameProvider("nestedobject");
}
}
@Override
protected @NotNull Query getNestedQuery1() {
return NativeQuery.builder().withQuery( //
nested(n -> n //
.path("car") //
.query(bool(b -> b //
.must(termQueryAsQuery("car.name", "saturn")) //
.must(termQueryAsQuery("car.model", "imprezza")) //
)) //
.scoreMode(ChildScoreMode.None) //
) //
)//
.build();
}
@Override
protected @NotNull Query getNestedQuery2() {
return NativeQuery.builder().withQuery( //
bool(b -> b //
.must(nested(n -> n //
.path("girlFriends") //
.query(termQueryAsQuery("girlFriends.type", "temp")) //
.scoreMode(ChildScoreMode.None) //
)) //
.must(nested(n -> n //
.path("girlFriends.cars") //
.query(termQueryAsQuery("girlFriends.cars.name", "Ford".toLowerCase())) //
.scoreMode(ChildScoreMode.None) //
)) //
) //
)//
.build();
}
@Override
protected @NotNull Query getNestedQuery3() {
return NativeQuery.builder().withQuery( //
nested(n -> n //
.path("books") //
.query(bool(b -> b //
.must(termQueryAsQuery("books.name", "java")) //
)) //
.scoreMode(ChildScoreMode.None) //
) //
)//
.build();
}
@Override
protected @NotNull Query getNestedQuery4() {
return NativeQuery.builder().withQuery( //
nested(n -> n //
.path("buckets") //
.query(termQueryAsQuery("buckets.1", "test3")) //
.scoreMode(ChildScoreMode.None) //
) //
)//
.build();
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright 2022 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.elasticsearch;
import static org.elasticsearch.index.query.QueryBuilders.*;
import org.apache.lucene.search.join.ScoreMode;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.utils.IndexNameProvider;
import org.springframework.test.context.ContextConfiguration;
/**
* @author Peter-Josef Meisch
*/
@ContextConfiguration(classes = { NestedObjectERHLCIntegrationTests.Config.class })
public class NestedObjectERHLCIntegrationTests extends NestedObjectIntegrationTests {
@Configuration
@Import({ ElasticsearchRestTemplateConfiguration.class })
static class Config {
@Bean
IndexNameProvider indexNameProvider() {
return new IndexNameProvider("nestedobject-es7");
}
}
@NotNull
protected Query getNestedQuery1() {
return new NativeSearchQueryBuilder().withQuery( //
nestedQuery("car", //
boolQuery() //
.must(termQuery("car.name", "saturn")) //
.must(termQuery("car.model", "imprezza")), //
ScoreMode.None)) //
.build();
}
@NotNull
protected Query getNestedQuery2() {
return new NativeSearchQueryBuilder().withQuery( //
boolQuery() //
.must(nestedQuery("girlFriends", //
termQuery("girlFriends.type", "temp"), //
ScoreMode.None)) //
.must(nestedQuery("girlFriends.cars", //
termQuery("girlFriends.cars.name", "Ford".toLowerCase()), //
ScoreMode.None))) //
.build();
}
@NotNull
protected Query getNestedQuery3() {
return new NativeSearchQueryBuilder().withQuery( //
nestedQuery("books", //
boolQuery() //
.must(termQuery("books.name", "java")), //
ScoreMode.None))//
.build();
}
@NotNull
protected Query getNestedQuery4() {
return new NativeSearchQueryBuilder().withQuery( //
nestedQuery("buckets", //
termQuery("buckets.1", "test3"), //
ScoreMode.None)) //
.build();
}
}

View File

@ -16,7 +16,6 @@
package org.springframework.data.elasticsearch; package org.springframework.data.elasticsearch;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.springframework.data.elasticsearch.utils.IdGenerator.*; import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -27,11 +26,9 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.lucene.search.join.ScoreMode; import org.jetbrains.annotations.NotNull;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
@ -40,18 +37,15 @@ import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.InnerField; import org.springframework.data.elasticsearch.annotations.InnerField;
import org.springframework.data.elasticsearch.annotations.MultiField; import org.springframework.data.elasticsearch.annotations.MultiField;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations; import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.IndexOperations;
import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.IndexQuery; import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.data.elasticsearch.utils.IndexInitializer; import org.springframework.data.elasticsearch.utils.IndexNameProvider;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.test.context.ContextConfiguration;
/** /**
* @author Rizwan Idrees * @author Rizwan Idrees
@ -61,21 +55,23 @@ import org.springframework.test.context.ContextConfiguration;
* @author Mark Paluch * @author Mark Paluch
*/ */
@SpringIntegrationTest @SpringIntegrationTest
@ContextConfiguration(classes = { ElasticsearchRestTemplateConfiguration.class }) public abstract class NestedObjectIntegrationTests {
public class NestedObjectTests {
@Autowired private IndexNameProvider indexNameProvider;
@Autowired private ElasticsearchOperations operations; @Autowired private ElasticsearchOperations operations;
private final List<Class<?>> entityClasses = Arrays.asList(Book.class, Person.class, PersonMultipleLevelNested.class); private final List<Class<?>> entityClasses = Arrays.asList(Book.class, Person.class, PersonMultipleLevelNested.class);
@BeforeEach @BeforeEach
public void before() { public void before() {
entityClasses.stream().map(operations::indexOps).forEach(IndexInitializer::init); indexNameProvider.increment();
entityClasses.stream().map(operations::indexOps).forEach(IndexOperations::createWithMapping);
} }
@AfterEach @Test
void tearDown() { @Order(java.lang.Integer.MAX_VALUE)
entityClasses.forEach(clazz -> operations.indexOps(clazz).delete()); void cleanup() {
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete();
} }
@Test @Test
@ -125,19 +121,18 @@ public class NestedObjectTests {
indexQueries.add(indexQuery1); indexQueries.add(indexQuery1);
indexQueries.add(indexQuery2); indexQueries.add(indexQuery2);
IndexCoordinates index = IndexCoordinates.of("test-index-person"); operations.bulkIndex(indexQueries, Person.class);
operations.bulkIndex(indexQueries, index);
operations.indexOps(Person.class).refresh(); operations.indexOps(Person.class).refresh();
QueryBuilder builder = nestedQuery("car", Query searchQuery = getNestedQuery1();
boolQuery().must(termQuery("car.name", "saturn")).must(termQuery("car.model", "imprezza")), ScoreMode.None); SearchHits<Person> persons = operations.search(searchQuery, Person.class);
Query searchQuery = new NativeSearchQueryBuilder().withQuery(builder).build();
SearchHits<Person> persons = operations.search(searchQuery, Person.class, index);
assertThat(persons).hasSize(1); assertThat(persons).hasSize(1);
} }
@NotNull
abstract protected Query getNestedQuery1();
@Test @Test
public void shouldIndexMultipleLevelNestedObject() { public void shouldIndexMultipleLevelNestedObject() {
@ -145,12 +140,10 @@ public class NestedObjectTests {
List<IndexQuery> indexQueries = createPerson(); List<IndexQuery> indexQueries = createPerson();
// when // when
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-person-multiple-level-nested")); operations.bulkIndex(indexQueries, PersonMultipleLevelNested.class);
operations.indexOps(PersonMultipleLevelNested.class).refresh();
// then // then
PersonMultipleLevelNested personIndexed = operations.get("1", PersonMultipleLevelNested.class, PersonMultipleLevelNested personIndexed = operations.get("1", PersonMultipleLevelNested.class);
IndexCoordinates.of("test-index-person-multiple-level-nested"));
assertThat(personIndexed).isNotNull(); assertThat(personIndexed).isNotNull();
} }
@ -161,7 +154,7 @@ public class NestedObjectTests {
List<IndexQuery> indexQueries = createPerson(); List<IndexQuery> indexQueries = createPerson();
// when // when
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-person-multiple-level-nested")); operations.bulkIndex(indexQueries, PersonMultipleLevelNested.class);
// then // then
Map<String, Object> mapping = operations.indexOps(PersonMultipleLevelNested.class).getMapping(); Map<String, Object> mapping = operations.indexOps(PersonMultipleLevelNested.class).getMapping();
@ -180,24 +173,21 @@ public class NestedObjectTests {
List<IndexQuery> indexQueries = createPerson(); List<IndexQuery> indexQueries = createPerson();
// when // when
IndexCoordinates index = IndexCoordinates.of("test-index-person-multiple-level-nested"); operations.bulkIndex(indexQueries, PersonMultipleLevelNested.class);
operations.bulkIndex(indexQueries, index);
operations.indexOps(PersonMultipleLevelNested.class).refresh();
// then // then
BoolQueryBuilder builder = boolQuery(); Query searchQuery = getNestedQuery2();
builder.must(nestedQuery("girlFriends", termQuery("girlFriends.type", "temp"), ScoreMode.None)).must(
nestedQuery("girlFriends.cars", termQuery("girlFriends.cars.name", "Ford".toLowerCase()), ScoreMode.None));
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(builder).build();
SearchHits<PersonMultipleLevelNested> personIndexed = operations.search(searchQuery, SearchHits<PersonMultipleLevelNested> personIndexed = operations.search(searchQuery,
PersonMultipleLevelNested.class, index); PersonMultipleLevelNested.class);
assertThat(personIndexed).isNotNull(); assertThat(personIndexed).isNotNull();
assertThat(personIndexed.getTotalHits()).isEqualTo(1); assertThat(personIndexed.getTotalHits()).isEqualTo(1);
assertThat(personIndexed.getSearchHit(0).getContent().getId()).isEqualTo("1"); assertThat(personIndexed.getSearchHit(0).getContent().getId()).isEqualTo("1");
} }
@NotNull
abstract protected Query getNestedQuery2();
private List<IndexQuery> createPerson() { private List<IndexQuery> createPerson() {
PersonMultipleLevelNested person1 = new PersonMultipleLevelNested(); PersonMultipleLevelNested person1 = new PersonMultipleLevelNested();
@ -320,20 +310,19 @@ public class NestedObjectTests {
indexQueries.add(indexQuery1); indexQueries.add(indexQuery1);
indexQueries.add(indexQuery2); indexQueries.add(indexQuery2);
IndexCoordinates index = IndexCoordinates.of("test-index-person"); operations.bulkIndex(indexQueries, Person.class);
operations.bulkIndex(indexQueries, index);
operations.indexOps(Person.class).refresh();
// when // when
QueryBuilder builder = nestedQuery("books", boolQuery().must(termQuery("books.name", "java")), ScoreMode.None); Query searchQuery = getNestedQuery3();
SearchHits<Person> persons = operations.search(searchQuery, Person.class);
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(builder).build();
SearchHits<Person> persons = operations.search(searchQuery, Person.class, index);
// then // then
assertThat(persons).hasSize(1); assertThat(persons).hasSize(1);
} }
@NotNull
abstract protected Query getNestedQuery3();
@Test // DATAES-73 @Test // DATAES-73
public void shouldIndexAndSearchMapAsNestedType() { public void shouldIndexAndSearchMapAsNestedType() {
@ -369,20 +358,20 @@ public class NestedObjectTests {
indexQueries.add(indexQuery2); indexQueries.add(indexQuery2);
// when // when
IndexCoordinates index = IndexCoordinates.of("test-index-book-nested-objects"); operations.bulkIndex(indexQueries, Book.class);
operations.bulkIndex(indexQueries, index);
operations.indexOps(Book.class).refresh();
// then // then
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder() Query searchQuery = getNestedQuery4();
.withQuery(nestedQuery("buckets", termQuery("buckets.1", "test3"), ScoreMode.None)).build(); SearchHits<Book> books = operations.search(searchQuery, Book.class);
SearchHits<Book> books = operations.search(searchQuery, Book.class, index);
assertThat(books.getSearchHits()).hasSize(1); assertThat(books.getSearchHits()).hasSize(1);
assertThat(books.getSearchHit(0).getContent().getId()).isEqualTo(book2.getId()); assertThat(books.getSearchHit(0).getContent().getId()).isEqualTo(book2.getId());
} }
@Document(indexName = "test-index-book-nested-objects") @NotNull
abstract protected Query getNestedQuery4();
@Document(indexName = "#{@indexNameProvider.indexName()}-book")
static class Book { static class Book {
@Nullable @Nullable
@ -443,7 +432,7 @@ public class NestedObjectTests {
} }
} }
@Document(indexName = "test-index-person") @Document(indexName = "#{@indexNameProvider.indexName()}-person")
static class Person { static class Person {
@Nullable @Nullable
@Id private String id; @Id private String id;
@ -513,7 +502,7 @@ public class NestedObjectTests {
} }
} }
@Document(indexName = "test-index-person-multiple-level-nested") @Document(indexName = "#{@indexNameProvider.indexName()}-person-multiple-nested")
static class PersonMultipleLevelNested { static class PersonMultipleLevelNested {
@Nullable @Nullable
@Id private String id; @Id private String id;

View File

@ -30,7 +30,8 @@ import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.data.elasticsearch.client.reactive.ReactiveRestClients; import org.springframework.data.elasticsearch.client.erhlc.ReactiveRestClients;
import org.springframework.data.elasticsearch.client.erhlc.RestClients;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;

View File

@ -44,7 +44,8 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchClients; import org.springframework.data.elasticsearch.client.elc.ElasticsearchClients;
import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.reactive.ReactiveRestClients; import org.springframework.data.elasticsearch.client.erhlc.ReactiveRestClients;
import org.springframework.data.elasticsearch.client.erhlc.RestClients;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.WireMockServer;
@ -400,7 +401,7 @@ public class RestClientsTest {
/** /**
* {@link ClientUnderTestFactory} implementation for the * {@link ClientUnderTestFactory} implementation for the
* {@link org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient}. * {@link org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient}.
*/ */
static class ReactiveERHLCUnderTestFactory extends ClientUnderTestFactory { static class ReactiveERHLCUnderTestFactory extends ClientUnderTestFactory {
@ -411,7 +412,7 @@ public class RestClientsTest {
@Override @Override
ClientUnderTest create(ClientConfiguration clientConfiguration) { ClientUnderTest create(ClientConfiguration clientConfiguration) {
org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient client = ReactiveRestClients org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient client = ReactiveRestClients
.create(clientConfiguration); .create(clientConfiguration);
return new ClientUnderTest() { return new ClientUnderTest() {
@Override @Override

View File

@ -0,0 +1,492 @@
/*
* Copyright 2019-2022 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.elasticsearch.client.elc;
import static org.skyscreamer.jsonassert.JSONAssert.*;
import static org.springframework.data.elasticsearch.client.elc.JsonUtils.*;
import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import org.assertj.core.api.SoftAssertions;
import org.json.JSONException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.InnerField;
import org.springframework.data.elasticsearch.annotations.MultiField;
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
import org.springframework.data.elasticsearch.core.geo.GeoJson;
import org.springframework.data.elasticsearch.core.geo.GeoJsonPoint;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
import org.springframework.data.elasticsearch.core.query.Criteria;
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
import org.springframework.data.elasticsearch.core.query.FetchSourceFilterBuilder;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.SourceFilter;
import org.springframework.lang.Nullable;
/**
* Tests for the mapping of {@link CriteriaQuery} by a {@link MappingElasticsearchConverter}. In the same package as
* {@link org.springframework.data.elasticsearch.client.elc.CriteriaQueryProcessor} as this is needed to get the String
* representation to assert.
*
* @author Peter-Josef Meisch
* @author Sascha Woo
* @author vdisk
*/
public class CriteriaQueryMappingUnitTests {
private JsonpMapper mapper = new JacksonJsonpMapper();
MappingElasticsearchConverter mappingElasticsearchConverter;
// region setup
@BeforeEach
void setUp() {
SimpleElasticsearchMappingContext mappingContext = new SimpleElasticsearchMappingContext();
mappingContext.setInitialEntitySet(Collections.singleton(Person.class));
mappingContext.afterPropertiesSet();
mappingElasticsearchConverter = new MappingElasticsearchConverter(mappingContext, new GenericConversionService());
mappingElasticsearchConverter.afterPropertiesSet();
}
// endregion
// region tests
@Test // DATAES-716
void shouldMapNamesAndConvertValuesInCriteriaQuery() throws JSONException {
// use POJO properties and types in the query building
CriteriaQuery criteriaQuery = new CriteriaQuery( //
new Criteria("birthDate") //
.between(LocalDate.of(1989, 11, 9), LocalDate.of(1990, 11, 9)) //
.or("birthDate").is(LocalDate.of(2019, 12, 28)) //
);
// mapped field name and converted parameter
var expected = """
{
"bool": {
"should": [
{
"range": {
"birth-date": {
"gte": "09.11.1989",
"lte": "09.11.1990"
}
}
},
{
"query_string": {
"default_operator": "and",
"fields": [
"birth-date"
],
"query": "28.12.2019"
}
}
]
}
}
""";
mappingElasticsearchConverter.updateQuery(criteriaQuery, Person.class);
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteriaQuery.getCriteria()), mapper);
assertEquals(expected, queryString, false);
}
@Test // #1668
void shouldMapNamesAndConvertValuesInCriteriaQueryForSubCriteria() throws JSONException {
// use POJO properties and types in the query building
CriteriaQuery criteriaQuery = new CriteriaQuery( //
Criteria.or().subCriteria(Criteria.where("birthDate") //
.between(LocalDate.of(1989, 11, 9), LocalDate.of(1990, 11, 9))) //
.subCriteria(Criteria.where("birthDate").is(LocalDate.of(2019, 12, 28))) //
);
// mapped field name and converted parameter
String expected = """
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"range": {
"birth-date": {
"gte": "09.11.1989",
"lte": "09.11.1990"
}
}
}
]
}
},
{
"bool": {
"must": [
{
"query_string": {
"default_operator": "and",
"fields": [
"birth-date"
],
"query": "28.12.2019"
}
}
]
}
}
]
}
}
""";
mappingElasticsearchConverter.updateQuery(criteriaQuery, Person.class);
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteriaQuery.getCriteria()), mapper);
assertEquals(expected, queryString, false);
}
@Test // #1668
void shouldMapNamesAndConvertValuesInCriteriaQueryForSubCriteriaWithDate() throws JSONException {
// use POJO properties and types in the query building
CriteriaQuery criteriaQuery = new CriteriaQuery( //
Criteria.or().subCriteria(Criteria.where("birthDate") //
.between(LocalDate.of(1989, 11, 9), LocalDate.of(1990, 11, 9))) //
.subCriteria(Criteria.where("createdDate").is(new Date(383745721653L))) //
);
// mapped field name and converted parameter
String expected = """
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"range": {
"birth-date": {
"gte": "09.11.1989",
"lte": "09.11.1990"
}
}
}
]
}
},
{
"bool": {
"must": [
{
"query_string": {
"default_operator": "and",
"fields": [
"created-date"
],
"query": "383745721653"
}
}
]
}
}
]
}
} """;
mappingElasticsearchConverter.updateQuery(criteriaQuery, Person.class);
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteriaQuery.getCriteria()), mapper);
assertEquals(expected, queryString, false);
}
@Test // DATAES-706
void shouldMapNamesAndValuesInSubCriteriaQuery() throws JSONException {
CriteriaQuery criteriaQuery = new CriteriaQuery( //
new Criteria("firstName").matches("John") //
.subCriteria(new Criteria("birthDate") //
.between(LocalDate.of(1989, 11, 9), LocalDate.of(1990, 11, 9)) //
.or("birthDate").is(LocalDate.of(2019, 12, 28))));
String expected = """
{
"bool": {
"must": [
{
"match": {
"first-name": {
"query": "John"
}
}
},
{
"bool": {
"should": [
{
"range": {
"birth-date": {
"gte": "09.11.1989",
"lte": "09.11.1990"
}
}
},
{
"query_string": {
"default_operator": "and",
"fields": [
"birth-date"
],
"query": "28.12.2019"
}
}
]
}
}
]
}
} """;
mappingElasticsearchConverter.updateQuery(criteriaQuery, Person.class);
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteriaQuery.getCriteria()), mapper);
assertEquals(expected, queryString, false);
}
@Test // DATAES-931
@DisplayName("should map names in GeoJson query")
void shouldMapNamesInGeoJsonQuery() throws JSONException {
GeoJsonPoint geoJsonPoint = GeoJsonPoint.of(1.2, 3.4);
CriteriaQuery criteriaQuery = new CriteriaQuery(new Criteria("geoShapeField").intersects(geoJsonPoint));
String expected = """
{
"geo_shape": {
"geo-shape-field": {
"shape": {
"type": "Point",
"coordinates": [
1.2,
3.4
]
},
"relation": "intersects"
}
}
}
""";
mappingElasticsearchConverter.updateQuery(criteriaQuery, GeoShapeEntity.class);
var queryString = queryToJson(CriteriaFilterProcessor.createQuery(criteriaQuery.getCriteria()).get(), mapper);
assertEquals(expected, queryString, false);
}
@Test // #1753
@DisplayName("should map names and value in nested entities")
void shouldMapNamesAndValueInNestedEntities() throws JSONException {
String expected = """
{
"bool": {
"must": [
{
"nested": {
"path": "per-sons",
"query": {
"query_string": {
"default_operator": "and",
"fields": [
"per-sons.birth-date"
],
"query": "03.10.1999"
}
},
"score_mode": "avg"
}
}
]
}
}
""";
CriteriaQuery criteriaQuery = new CriteriaQuery(new Criteria("persons.birthDate").is(LocalDate.of(1999, 10, 3)));
mappingElasticsearchConverter.updateQuery(criteriaQuery, House.class);
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteriaQuery.getCriteria()), mapper);
assertEquals(expected, queryString, false);
}
@Test // #1753
@DisplayName("should map names and value in nested entities with sub-fields")
void shouldMapNamesAndValueInNestedEntitiesWithSubfields() throws JSONException {
String expected = """
{
"bool": {
"must": [
{
"nested": {
"path": "per-sons",
"query": {
"query_string": {
"default_operator": "and",
"fields": [
"per-sons.nick-name.keyword"
],
"query": "Foobar"
}
},
"score_mode": "avg"
}
}
]
}
} """;
CriteriaQuery criteriaQuery = new CriteriaQuery(new Criteria("persons.nickName.keyword").is("Foobar"));
mappingElasticsearchConverter.updateQuery(criteriaQuery, House.class);
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteriaQuery.getCriteria()), mapper);
assertEquals(expected, queryString, false);
}
@Test // #1761
@DisplayName("should map names and value in object entities")
void shouldMapNamesAndValueInObjectEntities() throws JSONException {
String expected = """
{
"bool": {
"must": [
{
"query_string": {
"default_operator": "and",
"fields": [
"per-sons.birth-date"
],
"query": "03.10.1999"
}
}
]
}
} """;
CriteriaQuery criteriaQuery = new CriteriaQuery(new Criteria("persons.birthDate").is(LocalDate.of(1999, 10, 3)));
mappingElasticsearchConverter.updateQuery(criteriaQuery, ObjectWithPerson.class);
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteriaQuery.getCriteria()), mapper);
assertEquals(expected, queryString, false);
}
@Test // #1778
@DisplayName("should map names in source fields and SourceFilters")
void shouldMapNamesInSourceFieldsAndSourceFilters() {
Query query = Query.findAll();
// Note: we don't care if these filters make sense here, this test is only about name mapping
query.addFields("firstName", "lastName");
query.addSourceFilter(new FetchSourceFilterBuilder().withIncludes("firstName").withExcludes("lastName").build());
mappingElasticsearchConverter.updateQuery(query, Person.class);
SoftAssertions softly = new SoftAssertions();
softly.assertThat(query.getFields()).containsExactly("first-name", "last-name");
SourceFilter sourceFilter = query.getSourceFilter();
softly.assertThat(sourceFilter).isNotNull();
softly.assertThat(sourceFilter.getIncludes()).containsExactly("first-name");
softly.assertThat(sourceFilter.getExcludes()).containsExactly("last-name");
softly.assertAll();
}
@Test
@DisplayName("should map names in source stored fields")
void shouldMapNamesInSourceStoredFields() {
Query query = Query.findAll();
query.addStoredFields("firstName", "lastName");
mappingElasticsearchConverter.updateQuery(query, Person.class);
SoftAssertions softly = new SoftAssertions();
List<String> storedFields = query.getStoredFields();
softly.assertThat(storedFields).isNotNull();
softly.assertThat(storedFields).containsExactly("first-name", "last-name");
softly.assertAll();
}
// endregion
// region helper functions
// endregion
// region test entities
static class Person {
@Nullable
@Id String id;
@Nullable
@Field(name = "first-name") String firstName;
@Nullable
@Field(name = "last-name") String lastName;
@Nullable
@MultiField(mainField = @Field(name = "nick-name"),
otherFields = { @InnerField(suffix = "keyword", type = FieldType.Keyword) }) String nickName;
@Nullable
@Field(name = "created-date", type = FieldType.Date, format = DateFormat.epoch_millis) Date createdDate;
@Nullable
@Field(name = "birth-date", type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") LocalDate birthDate;
}
static class House {
@Nullable
@Id String id;
@Nullable
@Field(name = "per-sons", type = FieldType.Nested) List<Person> persons;
}
static class ObjectWithPerson {
@Nullable
@Id String id;
@Nullable
@Field(name = "per-sons", type = FieldType.Object) List<Person> persons;
}
static class GeoShapeEntity {
@Nullable
@Field(name = "geo-shape-field") GeoJson<?> geoShapeField;
}
// endregion
}

View File

@ -0,0 +1,457 @@
/*
* Copyright 2020-2022 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.elasticsearch.client.elc;
import static org.skyscreamer.jsonassert.JSONAssert.*;
import static org.springframework.data.elasticsearch.client.elc.JsonUtils.*;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import org.json.JSONException;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.data.elasticsearch.core.query.Criteria;
/**
* @author Peter-Josef Meisch
*/
@SuppressWarnings("ConstantConditions")
class CriteriaQueryProcessorUnitTests {
private JsonpMapper mapper = new JacksonJsonpMapper();
private final CriteriaQueryProcessor queryProcessor = new CriteriaQueryProcessor();
@Test // DATAES-706
void shouldProcessTwoCriteriaWithAnd() throws JSONException {
String expected = """
{
"bool": {
"must": [
{
"query_string": {
"fields": [
"field1"
],
"query": "value1"
}
},
{
"query_string": {
"fields": [
"field2"
],
"query": "value2"
}
}
]
}
}
"""; //
Criteria criteria = new Criteria("field1").is("value1").and("field2").is("value2");
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
@Test // DATAES-706
void shouldProcessTwoCriteriaWithOr() throws JSONException {
String expected = """
{
"bool": {
"should": [
{
"query_string": {
"fields": [
"field1"
],
"query": "value1"
}
},
{
"query_string": {
"fields": [
"field2"
],
"query": "value2"
}
}
]
}
}
""";
Criteria criteria = new Criteria("field1").is("value1").or("field2").is("value2");
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
@Test // DATAES-706
void shouldProcessMixedCriteriaWithOrAnd() throws JSONException {
String expected = """
{
"bool": {
"must": [
{
"query_string": {
"fields": [
"field1"
],
"query": "value1"
}
},
{
"query_string": {
"fields": [
"field3"
],
"query": "value3"
}
}
],
"should": [
{
"query_string": {
"fields": [
"field2"
],
"query": "value2"
}
},
{
"query_string": {
"fields": [
"field4"
],
"query": "value4"
}
}
]
}
}
""";
Criteria criteria = new Criteria("field1").is("value1") //
.or("field2").is("value2") //
.and("field3").is("value3") //
.or("field4").is("value4"); //
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
@Test // DATAES-706
void shouldAddSubQuery() throws JSONException {
String expected = """
{
"bool": {
"must": [
{
"query_string": {
"fields": [
"lastName"
],
"query": "Miller"
}
},
{
"bool": {
"should": [
{
"query_string": {
"fields": [
"firstName"
],
"query": "John"
}
},
{
"query_string": {
"fields": [
"firstName"
],
"query": "Jack"
}
}
]
}
}
]
}
} """;
Criteria criteria = new Criteria("lastName").is("Miller")
.subCriteria(new Criteria().or("firstName").is("John").or("firstName").is("Jack"));
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
@Test // DATAES-706
void shouldProcessNestedSubCriteria() throws JSONException {
String expected = """
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"query_string": {
"fields": [
"lastName"
],
"query": "Miller"
}
},
{
"bool": {
"should": [
{
"query_string": {
"fields": [
"firstName"
],
"query": "John"
}
},
{
"query_string": {
"fields": [
"firstName"
],
"query": "Jack"
}
}
]
}
}
]
}
},
{
"bool": {
"must": [
{
"query_string": {
"fields": [
"lastName"
],
"query": "Smith"
}
},
{
"bool": {
"should": [
{
"query_string": {
"fields": [
"firstName"
],
"query": "Emma"
}
},
{
"query_string": {
"fields": [
"firstName"
],
"query": "Lucy"
}
}
]
}
}
]
}
}
]
}
}
""";
Criteria criteria = Criteria.or()
.subCriteria(new Criteria("lastName").is("Miller")
.subCriteria(new Criteria().or("firstName").is("John").or("firstName").is("Jack")))
.subCriteria(new Criteria("lastName").is("Smith")
.subCriteria(new Criteria().or("firstName").is("Emma").or("firstName").is("Lucy")));
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
@Test // DATAES-706
void shouldBuildMatchQuery() throws JSONException {
String expected = """
{
"bool": {
"must": [
{
"match": {
"field1": {
"operator": "or",
"query": "value1 value2"
}
}
}
]
}
}
""";
Criteria criteria = new Criteria("field1").matches("value1 value2");
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
@Test // DATAES-706
void shouldBuildMatchAllQuery() throws JSONException {
String expected = """
{
"bool": {
"must": [
{
"match": {
"field1": {
"operator": "and",
"query": "value1 value2"
}
}
}
]
}
} """;
Criteria criteria = new Criteria("field1").matchesAll("value1 value2");
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
@Test // #1753
@DisplayName("should build nested query")
void shouldBuildNestedQuery() throws JSONException {
String expected = """
{
"bool": {
"must": [
{
"nested": {
"path": "houses.inhabitants",
"query": {
"query_string": {
"fields": [
"houses.inhabitants.lastName"
],
"query": "murphy"
}
}
}
}
]
}
} """;
Criteria criteria = new Criteria("houses.inhabitants.lastName").is("murphy");
criteria.getField().setPath("houses.inhabitants");
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
@Test // #1909
@DisplayName("should build query for empty property")
void shouldBuildQueryForEmptyProperty() throws JSONException {
String expected = "{\n" + //
" \"bool\" : {\n" + //
" \"must\" : [\n" + //
" {\n" + //
" \"bool\" : {\n" + //
" \"must\" : [\n" + //
" {\n" + //
" \"exists\" : {\n" + //
" \"field\" : \"lastName\"" + //
" }\n" + //
" }\n" + //
" ],\n" + //
" \"must_not\" : [\n" + //
" {\n" + //
" \"wildcard\" : {\n" + //
" \"lastName\" : {\n" + //
" \"wildcard\" : \"*\"" + //
" }\n" + //
" }\n" + //
" }\n" + //
" ]\n" + //
" }\n" + //
" }\n" + //
" ]\n" + //
" }\n" + //
"}"; //
Criteria criteria = new Criteria("lastName").empty();
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
@Test // #1909
@DisplayName("should build query for non-empty property")
void shouldBuildQueryForNonEmptyProperty() throws JSONException {
String expected = "{\n" + //
" \"bool\" : {\n" + //
" \"must\" : [\n" + //
" {\n" + //
" \"wildcard\" : {\n" + //
" \"lastName\" : {\n" + //
" \"wildcard\" : \"*\"\n" + //
" }\n" + //
" }\n" + //
" }\n" + //
" ]\n" + //
" }\n" + //
"}\n"; //
Criteria criteria = new Criteria("lastName").notEmpty();
var queryString = queryToJson(CriteriaQueryProcessor.createQuery(criteria), mapper);
assertEquals(expected, queryString, false);
}
}

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import static org.skyscreamer.jsonassert.JSONAssert.*; import static org.skyscreamer.jsonassert.JSONAssert.*;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import static org.skyscreamer.jsonassert.JSONAssert.*; import static org.skyscreamer.jsonassert.JSONAssert.*;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.elasticsearch.search.internal.SearchContext.*; import static org.elasticsearch.search.internal.SearchContext.*;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*;
@ -45,14 +45,15 @@ import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.core.ElasticsearchIntegrationTests;
import org.springframework.data.elasticsearch.core.RefreshPolicy;
import org.springframework.data.elasticsearch.core.ScriptType;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.BaseQueryBuilder; import org.springframework.data.elasticsearch.core.query.BaseQueryBuilder;
import org.springframework.data.elasticsearch.core.query.FetchSourceFilterBuilder; import org.springframework.data.elasticsearch.core.query.FetchSourceFilterBuilder;
import org.springframework.data.elasticsearch.core.query.IndicesOptions; import org.springframework.data.elasticsearch.core.query.IndicesOptions;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.RescorerQuery; import org.springframework.data.elasticsearch.core.query.RescorerQuery;
import org.springframework.data.elasticsearch.core.query.ScriptField;
import org.springframework.data.elasticsearch.core.query.UpdateQuery; import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.utils.IndexNameProvider; import org.springframework.data.elasticsearch.utils.IndexNameProvider;
@ -288,4 +289,8 @@ public class ElasticsearchERHLCIntegrationTests extends ElasticsearchIntegration
assertThat(request.getScript().getType()).isEqualTo(org.elasticsearch.script.ScriptType.INLINE); assertThat(request.getScript().getType()).isEqualTo(org.elasticsearch.script.ScriptType.INLINE);
assertThat(request.getScript().getLang()).isEqualTo("painless"); assertThat(request.getScript().getLang()).isEqualTo("painless");
} }
private RequestFactory getRequestFactory() {
return ((ElasticsearchRestTemplate) operations).getRequestFactory();
}
} }

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;

View File

@ -13,26 +13,26 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import org.mockito.invocation.InvocationOnMock;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import reactor.test.StepVerifier; import reactor.test.StepVerifier;
import java.util.function.Function;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.invocation.InvocationOnMock;
import org.springframework.data.elasticsearch.client.ElasticsearchHost; import org.springframework.data.elasticsearch.client.ElasticsearchHost;
import org.springframework.data.elasticsearch.client.ElasticsearchHost.State; import org.springframework.data.elasticsearch.client.ElasticsearchHost.State;
import org.springframework.data.elasticsearch.client.reactive.HostProvider.Verification; import org.springframework.data.elasticsearch.client.erhlc.HostProvider.Verification;
import org.springframework.data.elasticsearch.client.reactive.ReactiveMockClientTestsUtils.MockDelegatingElasticsearchHostProvider; import org.springframework.data.elasticsearch.client.erhlc.ReactiveMockClientTestsUtils.MockDelegatingElasticsearchHostProvider;
import org.springframework.data.elasticsearch.client.reactive.ReactiveMockClientTestsUtils.MockWebClientProvider.Receive; import org.springframework.data.elasticsearch.client.erhlc.ReactiveMockClientTestsUtils.MockWebClientProvider.Receive;
import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.ClientResponse;
import java.util.function.Function;
/** /**
* @author Christoph Strobl * @author Christoph Strobl
* @author Peter-Josef Meisch * @author Peter-Josef Meisch

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;

View File

@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.springframework.data.elasticsearch.client.reactive.ReactiveMockClientTestsUtils.MockWebClientProvider.Receive.*; import static org.springframework.data.elasticsearch.client.erhlc.ReactiveMockClientTestsUtils.MockWebClientProvider.Receive.*;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import reactor.test.StepVerifier; import reactor.test.StepVerifier;
@ -46,8 +46,8 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
import org.springframework.data.elasticsearch.RestStatusException; import org.springframework.data.elasticsearch.RestStatusException;
import org.springframework.data.elasticsearch.client.reactive.ReactiveMockClientTestsUtils.MockDelegatingElasticsearchHostProvider; import org.springframework.data.elasticsearch.client.erhlc.ReactiveMockClientTestsUtils.MockDelegatingElasticsearchHostProvider;
import org.springframework.data.elasticsearch.client.reactive.ReactiveMockClientTestsUtils.MockWebClientProvider.Receive; import org.springframework.data.elasticsearch.client.erhlc.ReactiveMockClientTestsUtils.MockWebClientProvider.Receive;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
@ -42,7 +42,7 @@ import org.mockito.Mockito;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.data.elasticsearch.client.ElasticsearchHost; import org.springframework.data.elasticsearch.client.ElasticsearchHost;
import org.springframework.data.elasticsearch.client.reactive.ReactiveMockClientTestsUtils.MockWebClientProvider.Send; import org.springframework.data.elasticsearch.client.erhlc.ReactiveMockClientTestsUtils.MockWebClientProvider.Send;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.util; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.core; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.elasticsearch.index.query.QueryBuilders.*; import static org.elasticsearch.index.query.QueryBuilders.*;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.data.elasticsearch.client.reactive; package org.springframework.data.elasticsearch.client.erhlc;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
@ -25,8 +25,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.data.elasticsearch.client.ElasticsearchHost; import org.springframework.data.elasticsearch.client.ElasticsearchHost;
import org.springframework.data.elasticsearch.client.ElasticsearchHost.State; import org.springframework.data.elasticsearch.client.ElasticsearchHost.State;
import org.springframework.data.elasticsearch.client.NoReachableHostException; import org.springframework.data.elasticsearch.client.NoReachableHostException;
import org.springframework.data.elasticsearch.client.reactive.ReactiveMockClientTestsUtils.MockDelegatingElasticsearchHostProvider; import org.springframework.data.elasticsearch.client.erhlc.ReactiveMockClientTestsUtils.MockDelegatingElasticsearchHostProvider;
import org.springframework.data.elasticsearch.client.reactive.ReactiveMockClientTestsUtils.MockWebClientProvider.Receive; import org.springframework.data.elasticsearch.client.erhlc.ReactiveMockClientTestsUtils.MockWebClientProvider.Receive;
/** /**
* @author Christoph Strobl * @author Christoph Strobl

View File

@ -1,3 +0,0 @@
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
package org.springframework.data.elasticsearch.client.reactive;

View File

@ -28,9 +28,11 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.client.erhlc.AbstractElasticsearchConfiguration;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.client.erhlc.AbstractReactiveElasticsearchConfiguration;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate; import org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext; import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;

View File

@ -25,7 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration; import org.springframework.data.elasticsearch.client.erhlc.AbstractElasticsearchConfiguration;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;

View File

@ -26,7 +26,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.client.ClientConfiguration; import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchConfiguration; import org.springframework.data.elasticsearch.client.elc.ReactiveElasticsearchConfiguration;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration; import org.springframework.data.elasticsearch.client.erhlc.AbstractElasticsearchConfiguration;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations; import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository; import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository;
import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories; import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories;

View File

@ -24,9 +24,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.client.erhlc.AbstractElasticsearchConfiguration;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration; import org.springframework.data.elasticsearch.client.erhlc.AbstractReactiveElasticsearchConfiguration;
import org.springframework.data.elasticsearch.config.AbstractReactiveElasticsearchConfiguration; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository; import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository;
import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories; import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;

View File

@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.client.RestClientFactoryBean; import org.springframework.data.elasticsearch.client.erhlc.RestClientFactoryBean;
import org.springframework.data.elasticsearch.junit.jupiter.Tags; import org.springframework.data.elasticsearch.junit.jupiter.Tags;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;

View File

@ -29,7 +29,16 @@ import java.lang.Double;
import java.lang.Integer; import java.lang.Integer;
import java.lang.Long; import java.lang.Long;
import java.lang.Object; import java.lang.Object;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
@ -60,6 +69,7 @@ import org.springframework.data.elasticsearch.annotations.JoinTypeRelations;
import org.springframework.data.elasticsearch.annotations.MultiField; import org.springframework.data.elasticsearch.annotations.MultiField;
import org.springframework.data.elasticsearch.annotations.ScriptedField; import org.springframework.data.elasticsearch.annotations.ScriptedField;
import org.springframework.data.elasticsearch.annotations.Setting; import org.springframework.data.elasticsearch.annotations.Setting;
import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.document.Explanation; import org.springframework.data.elasticsearch.core.document.Explanation;
import org.springframework.data.elasticsearch.core.geo.GeoPoint; import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import org.springframework.data.elasticsearch.core.index.AliasAction; import org.springframework.data.elasticsearch.core.index.AliasAction;
@ -107,6 +117,8 @@ import org.springframework.lang.Nullable;
@SpringIntegrationTest @SpringIntegrationTest
public abstract class ElasticsearchIntegrationTests implements NewElasticsearchClientDevelopment { public abstract class ElasticsearchIntegrationTests implements NewElasticsearchClientDevelopment {
static final Integer INDEX_MAX_RESULT_WINDOW = 10_000;
private static final String MULTI_INDEX_PREFIX = "test-index"; private static final String MULTI_INDEX_PREFIX = "test-index";
private static final String MULTI_INDEX_ALL = MULTI_INDEX_PREFIX + "*"; private static final String MULTI_INDEX_ALL = MULTI_INDEX_PREFIX + "*";
private static final String MULTI_INDEX_1_NAME = MULTI_INDEX_PREFIX + "-1"; private static final String MULTI_INDEX_1_NAME = MULTI_INDEX_PREFIX + "-1";
@ -377,8 +389,7 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
.version(System.currentTimeMillis()).build(); .version(System.currentTimeMillis()).build();
IndexQuery indexQuery = getIndexQuery(sampleEntity); IndexQuery indexQuery = getIndexQuery(sampleEntity);
operations.index(indexQuery, IndexCoordinates.of(indexNameProvider.indexName())); operations.index(indexQuery, IndexCoordinates.of(indexNameProvider.indexName()));
Query query = getBuilderWithMatchAllQuery() Query query = getBuilderWithMatchAllQuery().withPreference("_local").build();
.withPreference("_local").build();
SearchHits<SampleEntity> searchHits = operations.search(query, SampleEntity.class, SearchHits<SampleEntity> searchHits = operations.search(query, SampleEntity.class,
IndexCoordinates.of(indexNameProvider.indexName())); IndexCoordinates.of(indexNameProvider.indexName()));
@ -395,11 +406,11 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
.version(System.currentTimeMillis()).build(); .version(System.currentTimeMillis()).build();
IndexQuery indexQuery = getIndexQuery(sampleEntity); IndexQuery indexQuery = getIndexQuery(sampleEntity);
operations.index(indexQuery, IndexCoordinates.of(indexNameProvider.indexName())); operations.index(indexQuery, IndexCoordinates.of(indexNameProvider.indexName()));
Query query = getBuilderWithMatchAllQuery() Query query = getBuilderWithMatchAllQuery().withPreference("_only_nodes:oops").build();
.withPreference("_only_nodes:oops").build();
assertThatThrownBy(() -> operations.search(query, SampleEntity.class, assertThatThrownBy(
IndexCoordinates.of(indexNameProvider.indexName()))).isInstanceOf(Exception.class); () -> operations.search(query, SampleEntity.class, IndexCoordinates.of(indexNameProvider.indexName())))
.isInstanceOf(Exception.class);
} }
@Test // DATAES-422 - Add support for IndicesOptions in search queries @Test // DATAES-422 - Add support for IndicesOptions in search queries
@ -675,7 +686,6 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
assertThat(searchHits.getSearchHit(0).getContent().getRate()).isEqualTo(sampleEntity2.getRate()); assertThat(searchHits.getSearchHit(0).getContent().getRate()).isEqualTo(sampleEntity2.getRate());
} }
@Test @Test
public void shouldSortResultsGivenMultipleSortCriteria() { public void shouldSortResultsGivenMultipleSortCriteria() {
@ -1000,8 +1010,7 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
FetchSourceFilterBuilder sourceFilter = new FetchSourceFilterBuilder(); FetchSourceFilterBuilder sourceFilter = new FetchSourceFilterBuilder();
sourceFilter.withIncludes("message"); sourceFilter.withIncludes("message");
Query searchQuery = getBuilderWithMatchAllQuery() Query searchQuery = getBuilderWithMatchAllQuery().withSourceFilter(sourceFilter.build()).build();
.withSourceFilter(sourceFilter.build()).build();
// when // when
SearchHits<SampleEntity> searchHits = operations.search(searchQuery, SampleEntity.class, SearchHits<SampleEntity> searchHits = operations.search(searchQuery, SampleEntity.class,
@ -1557,8 +1566,6 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
assertThat(indexedEntity.getMessage()).isEqualTo(messageAfterUpdate); assertThat(indexedEntity.getMessage()).isEqualTo(messageAfterUpdate);
} }
@Test @Test
public void shouldDoUpsertIfDocumentDoesNotExist() { public void shouldDoUpsertIfDocumentDoesNotExist() {
@ -1596,8 +1603,7 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
operations.index(idxQuery, index); operations.index(idxQuery, index);
// when // when
Query query = getBuilderWithMatchAllQuery() Query query = getBuilderWithMatchAllQuery().withIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN).build();
.withIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN).build();
SearchScrollHits<SampleEntity> scroll = ((AbstractElasticsearchTemplate) operations) SearchScrollHits<SampleEntity> scroll = ((AbstractElasticsearchTemplate) operations)
.searchScrollStart(scrollTimeInMillis, query, SampleEntity.class, index); .searchScrollStart(scrollTimeInMillis, query, SampleEntity.class, index);
@ -1629,7 +1635,6 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
queries.add(getTermQuery("message", "bc")); queries.add(getTermQuery("message", "bc"));
queries.add(getTermQuery("message", "ac")); queries.add(getTermQuery("message", "ac"));
List<SearchHits<SampleEntity>> searchHits = operations.multiSearch(queries, SampleEntity.class, List<SearchHits<SampleEntity>> searchHits = operations.multiSearch(queries, SampleEntity.class,
IndexCoordinates.of(indexNameProvider.indexName())); IndexCoordinates.of(indexNameProvider.indexName()));
@ -1655,8 +1660,8 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
queries.add(getTermQuery("message", "ab")); queries.add(getTermQuery("message", "ab"));
queries.add(getTermQuery("description", "bc")); queries.add(getTermQuery("description", "bc"));
List<SearchHits<?>> searchHitsList = operations.multiSearch(queries, Lists.newArrayList(SampleEntity.class, List<SearchHits<?>> searchHitsList = operations.multiSearch(queries,
Book.class), Lists.newArrayList(SampleEntity.class, Book.class),
IndexCoordinates.of(indexNameProvider.indexName(), bookIndex.getIndexName())); IndexCoordinates.of(indexNameProvider.indexName(), bookIndex.getIndexName()));
bookIndexOperations.delete(); bookIndexOperations.delete();
@ -2507,11 +2512,10 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
operations.bulkIndex(indexQueries, IndexCoordinates.of(indexNameProvider.indexName())); operations.bulkIndex(indexQueries, IndexCoordinates.of(indexNameProvider.indexName()));
// when // when
Query query = getBuilderWithMatchQuery("message", "message") Query query = getBuilderWithMatchQuery("message", "message").withPageable(PageRequest.of(0, 10)).build();
.withPageable(PageRequest.of(0, 10)).build();
SearchScrollHits<SampleEntity> scroll = ((AbstractElasticsearchTemplate) operations).searchScrollStart(1000, SearchScrollHits<SampleEntity> scroll = ((AbstractElasticsearchTemplate) operations).searchScrollStart(1000, query,
query, SampleEntity.class, IndexCoordinates.of(indexNameProvider.indexName())); SampleEntity.class, IndexCoordinates.of(indexNameProvider.indexName()));
List<SearchHit<SampleEntity>> sampleEntities = new ArrayList<>(); List<SearchHit<SampleEntity>> sampleEntities = new ArrayList<>();
while (scroll.hasSearchHits()) { while (scroll.hasSearchHits()) {
sampleEntities.addAll(scroll.getSearchHits()); sampleEntities.addAll(scroll.getSearchHits());
@ -2589,8 +2593,8 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
.withSort(Sort.by(Sort.Order.desc("message"))) // .withSort(Sort.by(Sort.Order.desc("message"))) //
.withPageable(PageRequest.of(0, 10)).build(); .withPageable(PageRequest.of(0, 10)).build();
SearchScrollHits<SampleEntity> scroll = ((AbstractElasticsearchTemplate) operations).searchScrollStart(1000, SearchScrollHits<SampleEntity> scroll = ((AbstractElasticsearchTemplate) operations).searchScrollStart(1000, query,
query, SampleEntity.class, IndexCoordinates.of(indexNameProvider.indexName())); SampleEntity.class, IndexCoordinates.of(indexNameProvider.indexName()));
List<SearchHit<SampleEntity>> sampleEntities = new ArrayList<>(); List<SearchHit<SampleEntity>> sampleEntities = new ArrayList<>();
while (scroll.hasSearchHits()) { while (scroll.hasSearchHits()) {
sampleEntities.addAll(scroll.getSearchHits()); sampleEntities.addAll(scroll.getSearchHits());
@ -2635,8 +2639,8 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
.build(); .build();
// when // when
SearchScrollHits<SampleEntity> scroll = ((AbstractElasticsearchTemplate) operations).searchScrollStart(1000, SearchScrollHits<SampleEntity> scroll = ((AbstractElasticsearchTemplate) operations).searchScrollStart(1000, query,
query, SampleEntity.class, IndexCoordinates.of(indexNameProvider.indexName())); SampleEntity.class, IndexCoordinates.of(indexNameProvider.indexName()));
List<SearchHit<SampleEntity>> sampleEntities = new ArrayList<>(); List<SearchHit<SampleEntity>> sampleEntities = new ArrayList<>();
while (scroll.hasSearchHits()) { while (scroll.hasSearchHits()) {
sampleEntities.addAll(scroll.getSearchHits()); sampleEntities.addAll(scroll.getSearchHits());
@ -2713,7 +2717,6 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
assertThat(searchHits.getSearchHit(1).getInnerHits("innerHits").getTotalHits()).isEqualTo(1); assertThat(searchHits.getSearchHit(1).getInnerHits("innerHits").getTotalHits()).isEqualTo(1);
} }
@Test // #1997 @Test // #1997
@DisplayName("should return document with inner hits size zero") @DisplayName("should return document with inner hits size zero")
void shouldReturnDocumentWithInnerHitsSizeZero() { void shouldReturnDocumentWithInnerHitsSizeZero() {
@ -2891,7 +2894,6 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
assertThat(searchHit.getScore()).isEqualTo(80f); assertThat(searchHit.getScore()).isEqualTo(80f);
} }
@Test @Test
// DATAES-738 // DATAES-738
void shouldSaveEntityWithIndexCoordinates() { void shouldSaveEntityWithIndexCoordinates() {
@ -3042,8 +3044,8 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
OptimisticEntity saved = operations.save(original); OptimisticEntity saved = operations.save(original);
List<MultiGetItem<OptimisticEntity>> retrievedList = operations.multiGet( List<MultiGetItem<OptimisticEntity>> retrievedList = operations.multiGet(
queryWithIds(Objects.requireNonNull(saved.getId())), queryWithIds(Objects.requireNonNull(saved.getId())), OptimisticEntity.class,
OptimisticEntity.class, operations.getIndexCoordinatesFor(OptimisticEntity.class)); operations.getIndexCoordinatesFor(OptimisticEntity.class));
assertThat(retrievedList).hasSize(1); assertThat(retrievedList).hasSize(1);
OptimisticEntity retrieved = retrievedList.get(0).getItem(); OptimisticEntity retrieved = retrievedList.get(0).getItem();
@ -3230,8 +3232,7 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
assertThat(hitIds.size()).isEqualTo(1); assertThat(hitIds.size()).isEqualTo(1);
assertThat(hitIds.get(0)).isEqualTo(aId2); assertThat(hitIds.get(0)).isEqualTo(aId2);
updatedHits = operations.search(getQueryForParentId("answer", qId1, null), updatedHits = operations.search(getQueryForParentId("answer", qId1, null), SampleJoinEntity.class);
SampleJoinEntity.class);
hitIds = updatedHits.getSearchHits().stream().map(new Function<SearchHit<SampleJoinEntity>, String>() { hitIds = updatedHits.getSearchHits().stream().map(new Function<SearchHit<SampleJoinEntity>, String>() {
@Override @Override
@ -3263,10 +3264,6 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
return document; return document;
} }
protected RequestFactory getRequestFactory() {
return ((ElasticsearchRestTemplate) operations).getRequestFactory();
}
@Test // DATAES-908 @Test // DATAES-908
void shouldFillVersionOnSaveOne() { void shouldFillVersionOnSaveOne() {
VersionedEntity saved = operations.save(new VersionedEntity()); VersionedEntity saved = operations.save(new VersionedEntity());
@ -3344,7 +3341,7 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
SearchHits<SampleEntity> searchHits = operations.search(queryAll, SampleEntity.class); SearchHits<SampleEntity> searchHits = operations.search(queryAll, SampleEntity.class);
SoftAssertions softly = new SoftAssertions(); SoftAssertions softly = new SoftAssertions();
softly.assertThat(searchHits.getTotalHits()).isEqualTo((long) RequestFactory.INDEX_MAX_RESULT_WINDOW); softly.assertThat(searchHits.getTotalHits()).isEqualTo((long) INDEX_MAX_RESULT_WINDOW);
softly.assertThat(searchHits.getTotalHitsRelation()).isEqualTo(TotalHitsRelation.GREATER_THAN_OR_EQUAL_TO); softly.assertThat(searchHits.getTotalHitsRelation()).isEqualTo(TotalHitsRelation.GREATER_THAN_OR_EQUAL_TO);
softly.assertAll(); softly.assertAll();
} }
@ -3475,8 +3472,7 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
Query query = getMatchAllQueryWithIncludesAndInlineExpressionScript("*", "scriptedRate", "doc['rate'] * factor", Query query = getMatchAllQueryWithIncludesAndInlineExpressionScript("*", "scriptedRate", "doc['rate'] * factor",
params); params);
SearchHits<ImmutableWithScriptedEntity> searchHits = operations.search(query, SearchHits<ImmutableWithScriptedEntity> searchHits = operations.search(query, ImmutableWithScriptedEntity.class);
ImmutableWithScriptedEntity.class);
assertThat(searchHits.getTotalHits()).isEqualTo(1); assertThat(searchHits.getTotalHits()).isEqualTo(1);
ImmutableWithScriptedEntity foundEntity = searchHits.getSearchHit(0).getContent(); ImmutableWithScriptedEntity foundEntity = searchHits.getSearchHit(0).getContent();
@ -3485,7 +3481,6 @@ public abstract class ElasticsearchIntegrationTests implements NewElasticsearchC
assertThat(foundEntity.getScriptedRate()).isEqualTo(84.0); assertThat(foundEntity.getScriptedRate()).isEqualTo(84.0);
} }
@Test // #1893 @Test // #1893
@DisplayName("should index document from source with version") @DisplayName("should index document from source with version")
void shouldIndexDocumentFromSourceWithVersion() { void shouldIndexDocumentFromSourceWithVersion() {

View File

@ -42,6 +42,7 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness; import org.mockito.quality.Strictness;
import org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate;
/** /**
* @author Roman Puchkovskiy * @author Roman Puchkovskiy

View File

@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Spy; import org.mockito.Spy;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.document.Document; import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.data.elasticsearch.core.event.AfterConvertCallback; import org.springframework.data.elasticsearch.core.event.AfterConvertCallback;
import org.springframework.data.elasticsearch.core.event.AfterSaveCallback; import org.springframework.data.elasticsearch.core.event.AfterSaveCallback;

View File

@ -23,7 +23,7 @@ import org.elasticsearch.index.query.NestedQueryBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.utils.IndexNameProvider; import org.springframework.data.elasticsearch.utils.IndexNameProvider;

View File

@ -20,7 +20,7 @@ import static org.elasticsearch.index.query.QueryBuilders.*;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.utils.IndexNameProvider; import org.springframework.data.elasticsearch.utils.IndexNameProvider;

View File

@ -26,8 +26,8 @@ import org.elasticsearch.search.collapse.CollapseBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.BaseQueryBuilder; import org.springframework.data.elasticsearch.core.query.BaseQueryBuilder;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.utils.IndexNameProvider; import org.springframework.data.elasticsearch.utils.IndexNameProvider;
@ -55,6 +55,7 @@ public class ReactiveElasticsearchERHLCIntegrationTests extends ReactiveElastics
return new NativeSearchQueryBuilder().withQuery(matchAllQuery()) return new NativeSearchQueryBuilder().withQuery(matchAllQuery())
.addAggregation(AggregationBuilders.terms("messages").field("message")).build(); .addAggregation(AggregationBuilders.terms("messages").field("message")).build();
} }
@Override @Override
protected BaseQueryBuilder<?, ?> getBuilderWithMatchAllQuery() { protected BaseQueryBuilder<?, ?> getBuilderWithMatchAllQuery() {
return new NativeSearchQueryBuilder().withQuery(matchAllQuery()); return new NativeSearchQueryBuilder().withQuery(matchAllQuery());

View File

@ -62,6 +62,9 @@ import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Mapping; import org.springframework.data.elasticsearch.annotations.Mapping;
import org.springframework.data.elasticsearch.annotations.Setting; import org.springframework.data.elasticsearch.annotations.Setting;
import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQuery;
import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.document.Explanation; import org.springframework.data.elasticsearch.core.document.Explanation;
import org.springframework.data.elasticsearch.core.index.AliasAction; import org.springframework.data.elasticsearch.core.index.AliasAction;
import org.springframework.data.elasticsearch.core.index.AliasActionParameters; import org.springframework.data.elasticsearch.core.index.AliasActionParameters;
@ -707,8 +710,7 @@ public abstract class ReactiveElasticsearchIntegrationTests implements NewElasti
entity.rate = 42; entity.rate = 42;
index(entity); index(entity);
Query query = getBuilderWithMatchAllQuery().withSort(Sort.by(Sort.Direction.DESC, "rate")) Query query = getBuilderWithMatchAllQuery().withSort(Sort.by(Sort.Direction.DESC, "rate")).build();
.build();
operations.search(query, SampleEntity.class) // operations.search(query, SampleEntity.class) //
.as(StepVerifier::create) // .as(StepVerifier::create) //

View File

@ -55,8 +55,9 @@ import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness; import org.mockito.quality.Strictness;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.document.Document; import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.data.elasticsearch.core.event.ReactiveAfterConvertCallback; import org.springframework.data.elasticsearch.core.event.ReactiveAfterConvertCallback;
import org.springframework.data.elasticsearch.core.event.ReactiveAfterSaveCallback; import org.springframework.data.elasticsearch.core.event.ReactiveAfterSaveCallback;

View File

@ -49,7 +49,8 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.ScriptedField; import org.springframework.data.elasticsearch.annotations.ScriptedField;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.geo.GeoPoint; import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.Criteria; import org.springframework.data.elasticsearch.core.query.Criteria;

View File

@ -19,7 +19,7 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.utils.IndexNameProvider; import org.springframework.data.elasticsearch.utils.IndexNameProvider;

View File

@ -20,7 +20,7 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQuery;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.utils.IndexNameProvider; import org.springframework.data.elasticsearch.utils.IndexNameProvider;

View File

@ -28,9 +28,9 @@ import org.elasticsearch.search.aggregations.pipeline.StatsBucket;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.data.elasticsearch.client.erhlc.ElasticsearchAggregations;
import org.springframework.data.elasticsearch.client.erhlc.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.AggregationsContainer; import org.springframework.data.elasticsearch.core.AggregationsContainer;
import org.springframework.data.elasticsearch.core.ElasticsearchAggregations;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

Some files were not shown because too many files have changed in this diff Show More