Polishing

This commit is contained in:
Peter-Josef Meisch 2024-05-26 20:31:42 +02:00
parent fbe54e485b
commit 161439ae22
No known key found for this signature in database
GPG Key ID: DE108246970C7708
12 changed files with 303 additions and 327 deletions

View File

@ -15,9 +15,6 @@
*/ */
package org.springframework.data.elasticsearch.annotations; package org.springframework.data.elasticsearch.annotations;
import org.springframework.core.annotation.AliasFor;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited; import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable; import java.lang.annotation.Repeatable;
@ -25,6 +22,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/** /**
* Identifies an alias for the index. * Identifies an alias for the index.
* *
@ -33,7 +32,7 @@ import java.lang.annotation.Target;
*/ */
@Inherited @Inherited
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE}) @Target({ ElementType.TYPE })
@Repeatable(Aliases.class) @Repeatable(Aliases.class)
public @interface Alias { public @interface Alias {
/** /**

View File

@ -15,7 +15,6 @@
*/ */
package org.springframework.data.elasticsearch.annotations; package org.springframework.data.elasticsearch.annotations;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited; import java.lang.annotation.Inherited;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
@ -31,7 +30,7 @@ import java.lang.annotation.Target;
*/ */
@Inherited @Inherited
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE}) @Target({ ElementType.TYPE })
public @interface Aliases { public @interface Aliases {
Alias[] value(); Alias[] value();
} }

View File

@ -15,7 +15,6 @@
*/ */
package org.springframework.data.elasticsearch.annotations; package org.springframework.data.elasticsearch.annotations;
import org.springframework.core.annotation.AliasFor; import org.springframework.core.annotation.AliasFor;
/** /**

View File

@ -27,8 +27,6 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.elasticsearch.UncategorizedElasticsearchException; import org.springframework.data.elasticsearch.UncategorizedElasticsearchException;
@ -63,8 +61,6 @@ import org.springframework.util.Assert;
public class IndicesTemplate extends ChildTemplate<ElasticsearchTransport, ElasticsearchIndicesClient> public class IndicesTemplate extends ChildTemplate<ElasticsearchTransport, ElasticsearchIndicesClient>
implements IndexOperations { implements IndexOperations {
private static final Log LOGGER = LogFactory.getLog(IndicesTemplate.class);
// we need a cluster client as well because ES has put some methods from the indices API into the cluster client // we need a cluster client as well because ES has put some methods from the indices API into the cluster client
// (component templates) // (component templates)
private final ClusterTemplate clusterTemplate; private final ClusterTemplate clusterTemplate;
@ -242,8 +238,7 @@ public class IndicesTemplate extends ChildTemplate<ElasticsearchTransport, Elast
GetMappingRequest getMappingRequest = requestConverter.indicesGetMappingRequest(indexCoordinates); GetMappingRequest getMappingRequest = requestConverter.indicesGetMappingRequest(indexCoordinates);
GetMappingResponse getMappingResponse = execute(client -> client.getMapping(getMappingRequest)); GetMappingResponse getMappingResponse = execute(client -> client.getMapping(getMappingRequest));
Document mappingResponse = responseConverter.indicesGetMapping(getMappingResponse, indexCoordinates); return responseConverter.indicesGetMapping(getMappingResponse, indexCoordinates);
return mappingResponse;
} }
@Override @Override

View File

@ -15,14 +15,12 @@
*/ */
package org.springframework.data.elasticsearch.client.elc; package org.springframework.data.elasticsearch.client.elc;
import static org.springframework.util.StringUtils.hasText; import static org.springframework.util.StringUtils.*;
import co.elastic.clients.elasticsearch._types.AcknowledgedResponseBase; import co.elastic.clients.elasticsearch._types.AcknowledgedResponseBase;
import co.elastic.clients.elasticsearch.indices.*; import co.elastic.clients.elasticsearch.indices.*;
import co.elastic.clients.transport.ElasticsearchTransport; import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.endpoints.BooleanResponse; import co.elastic.clients.transport.endpoints.BooleanResponse;
import org.springframework.data.elasticsearch.core.mapping.Alias;
import org.springframework.data.elasticsearch.core.mapping.CreateIndexSettings;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -49,6 +47,8 @@ import org.springframework.data.elasticsearch.core.index.GetIndexTemplateRequest
import org.springframework.data.elasticsearch.core.index.GetTemplateRequest; import org.springframework.data.elasticsearch.core.index.GetTemplateRequest;
import org.springframework.data.elasticsearch.core.index.PutIndexTemplateRequest; import org.springframework.data.elasticsearch.core.index.PutIndexTemplateRequest;
import org.springframework.data.elasticsearch.core.index.PutTemplateRequest; import org.springframework.data.elasticsearch.core.index.PutTemplateRequest;
import org.springframework.data.elasticsearch.core.mapping.Alias;
import org.springframework.data.elasticsearch.core.mapping.CreateIndexSettings;
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;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;

View File

@ -113,7 +113,6 @@ import org.springframework.util.StringUtils;
* @author Haibo Liu * @author Haibo Liu
* @since 4.4 * @since 4.4
*/ */
@SuppressWarnings("ClassCanBeRecord")
class RequestConverter extends AbstractQueryProcessor { class RequestConverter extends AbstractQueryProcessor {
private static final Log LOGGER = LogFactory.getLog(RequestConverter.class); private static final Log LOGGER = LogFactory.getLog(RequestConverter.class);
@ -172,7 +171,8 @@ class RequestConverter extends AbstractQueryProcessor {
})); }));
} }
private co.elastic.clients.elasticsearch.indices.Alias.Builder buildAlias(AliasActionParameters parameters, co.elastic.clients.elasticsearch.indices.Alias.Builder aliasBuilder) { private co.elastic.clients.elasticsearch.indices.Alias.Builder buildAlias(AliasActionParameters parameters,
co.elastic.clients.elasticsearch.indices.Alias.Builder aliasBuilder) {
if (parameters.getRouting() != null) { if (parameters.getRouting() != null) {
aliasBuilder.routing(parameters.getRouting()); aliasBuilder.routing(parameters.getRouting());
@ -239,13 +239,13 @@ class RequestConverter extends AbstractQueryProcessor {
public CreateIndexRequest indicesCreateRequest(CreateIndexSettings indexSettings) { public CreateIndexRequest indicesCreateRequest(CreateIndexSettings indexSettings) {
Map<String, co.elastic.clients.elasticsearch.indices.Alias> aliases = new HashMap<>(); Map<String, co.elastic.clients.elasticsearch.indices.Alias> aliases = new HashMap<>();
for (Alias alias : indexSettings.getAliases()) { for (Alias alias : indexSettings.getAliases()) {
co.elastic.clients.elasticsearch.indices.Alias esAlias = co.elastic.clients.elasticsearch.indices.Alias.of(ab -> ab.filter(getQuery(alias.getFilter(), null)) co.elastic.clients.elasticsearch.indices.Alias esAlias = co.elastic.clients.elasticsearch.indices.Alias
.of(ab -> ab.filter(getQuery(alias.getFilter(), null))
.routing(alias.getRouting()) .routing(alias.getRouting())
.indexRouting(alias.getIndexRouting()) .indexRouting(alias.getIndexRouting())
.searchRouting(alias.getSearchRouting()) .searchRouting(alias.getSearchRouting())
.isHidden(alias.getHidden()) .isHidden(alias.getHidden())
.isWriteIndex(alias.getWriteIndex()) .isWriteIndex(alias.getWriteIndex()));
);
aliases.put(alias.getAlias(), esAlias); aliases.put(alias.getAlias(), esAlias);
} }
@ -1026,7 +1026,7 @@ class RequestConverter extends AbstractQueryProcessor {
order = sortField.order().jsonValue(); order = sortField.order().jsonValue();
} }
return sortField.field() + ":" + order; return sortField.field() + ':' + order;
}) })
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }
@ -1790,7 +1790,6 @@ class RequestConverter extends AbstractQueryProcessor {
return getEsQuery(query, (q) -> elasticsearchConverter.updateQuery(q, clazz)); return getEsQuery(query, (q) -> elasticsearchConverter.updateQuery(q, clazz));
} }
@SuppressWarnings("StatementWithEmptyBody")
private void addPostFilter(Query query, SearchRequest.Builder builder) { private void addPostFilter(Query query, SearchRequest.Builder builder) {
// we only need to handle NativeQuery here. filter from a CriteriaQuery are added into the query and not as post // we only need to handle NativeQuery here. filter from a CriteriaQuery are added into the query and not as post

View File

@ -15,12 +15,12 @@
*/ */
package org.springframework.data.elasticsearch.core.mapping; package org.springframework.data.elasticsearch.core.mapping;
import java.util.Objects;
import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.Objects;
/** /**
* Immutable Value object encapsulating index alias(es). * Immutable Value object encapsulating index alias(es).
* *
@ -36,40 +36,32 @@ public class Alias {
/** /**
* Query used to limit documents the alias can access. * Query used to limit documents the alias can access.
*/ */
@Nullable @Nullable private final Query filter;
private final Query filter;
/** /**
* Used to route indexing operations to a specific shard. * Used to route indexing operations to a specific shard.
*/ */
@Nullable @Nullable private final String indexRouting;
private final String indexRouting;
/** /**
* Used to route search operations to a specific shard. * Used to route search operations to a specific shard.
*/ */
@Nullable @Nullable private final String searchRouting;
private final String searchRouting;
/** /**
* Used to route indexing and search operations to a specific shard. * Used to route indexing and search operations to a specific shard.
*/ */
@Nullable @Nullable private final String routing;
private final String routing;
/** /**
* The alias is hidden? * The alias is hidden? By default, this is set to {@code false}.
* By default, this is set to {@code false}.
*/ */
@Nullable @Nullable private final Boolean isHidden;
private final Boolean isHidden;
/** /**
* The index is the 'write index' for the alias? * The index is the 'write index' for the alias? By default, this is set to {@code false}.
* By default, this is set to {@code false}.
*/ */
@Nullable @Nullable private final Boolean isWriteIndex;
private final Boolean isWriteIndex;
private Alias(Builder builder) { private Alias(Builder builder) {
this.alias = builder.alias; this.alias = builder.alias;
@ -124,8 +116,10 @@ public class Alias {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o)
if (!(o instanceof Alias that)) return false; return true;
if (!(o instanceof Alias that))
return false;
return Objects.equals(alias, that.alias) && Objects.equals(filter, that.filter) return Objects.equals(alias, that.alias) && Objects.equals(filter, that.filter)
&& Objects.equals(indexRouting, that.indexRouting) && Objects.equals(indexRouting, that.indexRouting)
@ -143,20 +137,14 @@ public class Alias {
public static class Builder { public static class Builder {
private final String alias; private final String alias;
@Nullable @Nullable private Query filter;
private Query filter;
@Nullable @Nullable private String indexRouting;
private String indexRouting; @Nullable private String searchRouting;
@Nullable @Nullable private String routing;
private String searchRouting;
@Nullable
private String routing;
@Nullable @Nullable private Boolean isHidden;
private Boolean isHidden; @Nullable private Boolean isWriteIndex;
@Nullable
private Boolean isWriteIndex;
public Builder(String alias) { public Builder(String alias) {
Assert.notNull(alias, "alias must not be null"); Assert.notNull(alias, "alias must not be null");
@ -206,8 +194,7 @@ public class Alias {
} }
/** /**
* The alias is hidden? * The alias is hidden? By default, this is set to {@code false}.
* By default, this is set to {@code false}.
*/ */
public Builder withHidden(@Nullable Boolean hidden) { public Builder withHidden(@Nullable Boolean hidden) {
isHidden = hidden; isHidden = hidden;
@ -216,8 +203,7 @@ public class Alias {
} }
/** /**
* The index is the 'write index' for the alias? * The index is the 'write index' for the alias? By default, this is set to {@code false}.
* By default, this is set to {@code false}.
*/ */
public Builder withWriteIndex(@Nullable Boolean writeIndex) { public Builder withWriteIndex(@Nullable Boolean writeIndex) {
isWriteIndex = writeIndex; isWriteIndex = writeIndex;

View File

@ -15,14 +15,14 @@
*/ */
package org.springframework.data.elasticsearch.core.mapping; package org.springframework.data.elasticsearch.core.mapping;
import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/** /**
* Encapsulating index mapping fields, settings, and index alias(es). * Encapsulating index mapping fields, settings, and index alias(es).
* *
@ -33,11 +33,9 @@ public class CreateIndexSettings {
private final IndexCoordinates indexCoordinates; private final IndexCoordinates indexCoordinates;
private final Set<Alias> aliases; private final Set<Alias> aliases;
@Nullable @Nullable private final Map<String, Object> settings;
private final Map<String, Object> settings;
@Nullable @Nullable private final Document mapping;
private final Document mapping;
private CreateIndexSettings(Builder builder) { private CreateIndexSettings(Builder builder) {
this.indexCoordinates = builder.indexCoordinates; this.indexCoordinates = builder.indexCoordinates;
@ -59,6 +57,7 @@ public class CreateIndexSettings {
return aliases.toArray(Alias[]::new); return aliases.toArray(Alias[]::new);
} }
@Nullable
public Map<String, Object> getSettings() { public Map<String, Object> getSettings() {
return settings; return settings;
} }
@ -69,14 +68,12 @@ public class CreateIndexSettings {
} }
public static class Builder { public static class Builder {
private IndexCoordinates indexCoordinates; private final IndexCoordinates indexCoordinates;
private final Set<Alias> aliases = new HashSet<>(); private final Set<Alias> aliases = new HashSet<>();
@Nullable @Nullable private Map<String, Object> settings;
private Map<String, Object> settings;
@Nullable @Nullable private Document mapping;
private Document mapping;
public Builder(IndexCoordinates indexCoordinates) { public Builder(IndexCoordinates indexCoordinates) {
Assert.notNull(indexCoordinates, "indexCoordinates must not be null"); Assert.notNull(indexCoordinates, "indexCoordinates must not be null");

View File

@ -15,6 +15,8 @@
*/ */
package org.springframework.data.elasticsearch.core.mapping; package org.springframework.data.elasticsearch.core.mapping;
import java.util.Set;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Dynamic; import org.springframework.data.elasticsearch.annotations.Dynamic;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
@ -25,8 +27,6 @@ import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.model.FieldNamingStrategy; import org.springframework.data.mapping.model.FieldNamingStrategy;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import java.util.Set;
/** /**
* ElasticsearchPersistentEntity * ElasticsearchPersistentEntity
* *
@ -76,7 +76,7 @@ public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, El
boolean isCreateIndexAndMapping(); boolean isCreateIndexAndMapping();
/** /**
* returns the {@link ElasticsearchPersistentProperty} with the given fieldName (may be set by the {@link Field} * returns the {@link ElasticsearchPersistentProperty} with the given fieldName (can be set by the {@link Field})
* annotation. * annotation.
* *
* @param fieldName to field name for the search, must not be {@literal null} * @param fieldName to field name for the search, must not be {@literal null}
@ -199,7 +199,7 @@ public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, El
boolean storeVersionInSource(); boolean storeVersionInSource();
/** /**
* @return if the mapping should be written to the index on repositry bootstrap even if the index already exists. * @return if the mapping should be written to the index on repository bootstrap even if the index already exists.
* @since 5.2 * @since 5.2
*/ */
boolean isAlwaysWriteMapping(); boolean isAlwaysWriteMapping();

View File

@ -258,12 +258,12 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
if (property.isIndexedIndexNameProperty()) { if (property.isIndexedIndexNameProperty()) {
if (!property.getActualType().isAssignableFrom(String.class)) { if (!property.getActualType().isAssignableFrom(String.class)) {
throw new MappingException(String.format("@IndexedIndexName annotation must be put on String property")); throw new MappingException("@IndexedIndexName annotation must be put on String property");
} }
if (indexedIndexNameProperty != null) { if (indexedIndexNameProperty != null) {
throw new MappingException( throw new MappingException(
String.format("@IndexedIndexName annotation can only be put on one property in an entity")); "@IndexedIndexName annotation can only be put on one property in an entity");
} }
this.indexedIndexNameProperty = property; this.indexedIndexNameProperty = property;
@ -653,8 +653,7 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
.withRouting(alias.routing()) .withRouting(alias.routing())
.withHidden(alias.isHidden()) .withHidden(alias.isHidden())
.withWriteIndex(alias.isWriteIndex()) .withWriteIndex(alias.isWriteIndex())
.build() .build());
);
} }
} }
} }

View File

@ -15,8 +15,8 @@
*/ */
package org.springframework.data.elasticsearch.core.index; package org.springframework.data.elasticsearch.core.index;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.Text; import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -71,7 +71,7 @@ public abstract class IndexOperationsIntegrationTests {
@Test @Test
@Order(java.lang.Integer.MAX_VALUE) @Order(java.lang.Integer.MAX_VALUE)
void cleanup() { void cleanup() {
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete(); operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + '*')).delete();
} }
@Test // #1646, #1718 @Test // #1646, #1718
@ -219,12 +219,13 @@ public abstract class IndexOperationsIntegrationTests {
} }
@Document(indexName = "#{@indexNameProvider.indexName()}", aliases = { @Document(indexName = "#{@indexNameProvider.indexName()}", aliases = {
@Alias(value = "first_alias", filter =@Filter(""" @Alias(value = "first_alias", filter = @Filter("""
{"bool" : {"must" : {"term" : {"type" : "abc"}}}} {"bool" : {"must" : {"term" : {"type" : "abc"}}}}
""")) """))
}) })
private static class EntityWithAliases { private static class EntityWithAliases {
@Nullable private @Id String id; @Nullable private @Id String id;
@Nullable
@Field(type = Text) private String type; @Field(type = Text) private String type;
@Nullable @Nullable
@ -236,6 +237,7 @@ public abstract class IndexOperationsIntegrationTests {
this.id = id; this.id = id;
} }
@Nullable
public String getType() { public String getType() {
return type; return type;
} }

View File

@ -17,14 +17,9 @@ package org.springframework.data.elasticsearch.core.index;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.skyscreamer.jsonassert.JSONAssert.*; import static org.skyscreamer.jsonassert.JSONAssert.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.Text; import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import static org.springframework.data.elasticsearch.core.IndexOperationsAdapter.*; import static org.springframework.data.elasticsearch.core.IndexOperationsAdapter.*;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.springframework.data.elasticsearch.annotations.Alias;
import org.springframework.data.elasticsearch.annotations.Filter;
import org.springframework.data.elasticsearch.client.elc.Queries;
import org.springframework.data.elasticsearch.core.query.StringQuery;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import reactor.test.StepVerifier; import reactor.test.StepVerifier;
@ -32,22 +27,27 @@ import java.time.LocalDate;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.json.JSONException; import org.json.JSONException;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order; 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;
import org.springframework.data.elasticsearch.annotations.Alias;
import org.springframework.data.elasticsearch.annotations.DateFormat; import org.springframework.data.elasticsearch.annotations.DateFormat;
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.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Filter;
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.elc.Queries;
import org.springframework.data.elasticsearch.core.IndexOperations; import org.springframework.data.elasticsearch.core.IndexOperations;
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.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.StringQuery;
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
import org.springframework.data.elasticsearch.utils.IndexNameProvider; import org.springframework.data.elasticsearch.utils.IndexNameProvider;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
@ -367,7 +367,8 @@ public abstract class ReactiveIndexOperationsIntegrationTests {
indexOperations.getAliasesForIndex(indexName) indexOperations.getAliasesForIndex(indexName)
.as(StepVerifier::create) .as(StepVerifier::create)
.assertNext(aliases -> { .assertNext(aliases -> {
AliasData result = aliases.values().stream().findFirst().orElse(new HashSet<>()).stream().findFirst().orElse(null); AliasData result = aliases.values().stream().findFirst().orElse(new HashSet<>()).stream().findFirst()
.orElse(null);
assertThat(result).isNotNull(); assertThat(result).isNotNull();
assertThat(result.getAlias()).isEqualTo("first_alias"); assertThat(result.getAlias()).isEqualTo("first_alias");
@ -437,7 +438,7 @@ public abstract class ReactiveIndexOperationsIntegrationTests {
} }
@Document(indexName = "#{@indexNameProvider.indexName()}", aliases = { @Document(indexName = "#{@indexNameProvider.indexName()}", aliases = {
@Alias(value = "first_alias", filter =@Filter(""" @Alias(value = "first_alias", filter = @Filter("""
{"bool" : {"must" : {"term" : {"type" : "abc"}}}} {"bool" : {"must" : {"term" : {"type" : "abc"}}}}
""")) """))
}) })