DATAES-841 - Remove deprecated type mappings code.

Original PR: #468
This commit is contained in:
Peter-Josef Meisch 2020-05-23 16:56:13 +02:00 committed by GitHub
parent dc6734db43
commit 0f84158e1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 80 additions and 142 deletions

View File

@ -10,6 +10,7 @@ You will notice similarities to the Spring data solr and mongodb support in the
include::reference/elasticsearch-new.adoc[leveloffset=+1]
include::reference/elasticsearch-migration-guide-3.2-4.0.adoc[leveloffset=+1]
include::reference/elasticsearch-migration-guide-4.0-4.1.adoc[leveloffset=+1]
[[preface.metadata]]
== Project Metadata

View File

@ -0,0 +1,9 @@
[[elasticsearch-migration-guide-4.0-4.1]]
== Upgrading from 4.0.x to 4.1.x
This section describes breaking changes from version 4.0.x to 4.1.x and how removed features can be replaced by new introduced features.
=== Removals
The _type mappings_ parameters of the `@Document` annotation and the `IndexCoordinates` object were removed. They had been deprecated in Spring Data Elasticsearch 4.0 and their values weren't used anymore.

View File

@ -53,17 +53,6 @@ public @interface Document {
*/
String indexName();
/**
* Mapping type name. <br/>
* deprecated as Elasticsearch does not support this anymore
* (@see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.3/removal-of-types.html">Elastisearch removal of types documentation</a>) and will remove it in
* Elasticsearch 8.
*
* @deprecated since 4.0
*/
@Deprecated
String type() default "";
/**
* Use server-side settings when creating the index.
*/

View File

@ -17,7 +17,6 @@ package org.springframework.data.elasticsearch.core.mapping;
import java.util.Arrays;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@ -34,29 +33,15 @@ public class IndexCoordinates {
public static final String TYPE = "_doc";
private final String[] indexNames;
private final String[] typeNames;
public static IndexCoordinates of(String... indexNames) {
Assert.notNull(indexNames, "indexNames must not be null");
return new IndexCoordinates(indexNames, null);
return new IndexCoordinates(indexNames);
}
private IndexCoordinates(String[] indexNames, @Nullable String[] typeNames) {
private IndexCoordinates(String[] indexNames) {
Assert.notEmpty(indexNames, "indexNames may not be null or empty");
this.indexNames = indexNames;
this.typeNames = typeNames != null ? typeNames : new String[] {};
}
/**
* Using Index types is deprecated in Elasticsearch.
*
* @param typeNames
* @return
*/
@Deprecated
public IndexCoordinates withTypes(String... typeNames) {
Assert.notEmpty(typeNames, "typeNames must not be null");
return new IndexCoordinates(this.indexNames, typeNames);
}
public String getIndexName() {
@ -67,20 +52,8 @@ public class IndexCoordinates {
return Arrays.copyOf(indexNames, indexNames.length);
}
@Deprecated
@Nullable
public String getTypeName() {
return typeNames.length > 0 ? typeNames[0] : null;
}
@Deprecated
public String[] getTypeNames() {
return Arrays.copyOf(typeNames, typeNames.length);
}
@Override
public String toString() {
return "IndexCoordinates{" + "indexNames=" + Arrays.toString(indexNames) + ", typeNames="
+ Arrays.toString(typeNames) + '}';
return "IndexCoordinates{" + "indexNames=" + Arrays.toString(indexNames) + '}';
}
}

View File

@ -15,9 +15,6 @@
*/
package org.springframework.data.elasticsearch.core.mapping;
import static org.springframework.util.StringUtils.*;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
@ -66,7 +63,6 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
private final SpelExpressionParser parser;
private @Nullable String indexName;
private @Nullable String indexType;
private boolean useServerConfiguration;
private short shards;
private short replicas;
@ -93,7 +89,6 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
Assert.hasText(document.indexName(),
" Unknown indexName. Make sure the indexName is defined. e.g @Document(indexName=\"foo\")");
this.indexName = document.indexName();
this.indexType = hasText(document.type()) ? document.type() : clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
this.useServerConfiguration = document.useServerConfiguration();
this.shards = document.shards();
this.replicas = document.replicas();
@ -124,19 +119,9 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
return getTypeInformation().getType().getSimpleName();
}
private String getIndexType() {
if (indexType != null) {
Expression expression = parser.parseExpression(indexType, ParserContext.TEMPLATE_EXPRESSION);
return expression.getValue(context, String.class);
}
return "";
}
@Override
public IndexCoordinates getIndexCoordinates() {
return IndexCoordinates.of(getIndexName()).withTypes(getIndexType());
return IndexCoordinates.of(getIndexName());
}
@Nullable

View File

@ -90,8 +90,7 @@ abstract class AbstractReactiveElasticsearchRepositoryQuery implements Repositor
Class<?> targetType = processor.getReturnedType().getTypeToRead();
String indexName = queryMethod.getEntityInformation().getIndexName();
String indexTypeName = queryMethod.getEntityInformation().getIndexTypeName();
IndexCoordinates index = IndexCoordinates.of(indexName).withTypes(indexTypeName);
IndexCoordinates index = IndexCoordinates.of(indexName);
ReactiveElasticsearchQueryExecution execution = getExecution(parameterAccessor,
new ResultProcessingConverter(processor));

View File

@ -121,7 +121,7 @@ public class NestedObjectTests {
indexQueries.add(indexQuery1);
indexQueries.add(indexQuery2);
IndexCoordinates index = IndexCoordinates.of("test-index-person").withTypes("user");
IndexCoordinates index = IndexCoordinates.of("test-index-person");
operations.bulkIndex(indexQueries, index);
operations.indexOps(Person.class).refresh();
@ -141,13 +141,12 @@ public class NestedObjectTests {
List<IndexQuery> indexQueries = createPerson();
// when
operations.bulkIndex(indexQueries,
IndexCoordinates.of("test-index-person-multiple-level-nested").withTypes("user"));
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-person-multiple-level-nested"));
operations.indexOps(PersonMultipleLevelNested.class).refresh();
// then
PersonMultipleLevelNested personIndexed = operations.get("1", PersonMultipleLevelNested.class,
IndexCoordinates.of("test-index-person-multiple-level-nested").withTypes("user"));
IndexCoordinates.of("test-index-person-multiple-level-nested"));
assertThat(personIndexed).isNotNull();
}
@ -158,8 +157,7 @@ public class NestedObjectTests {
List<IndexQuery> indexQueries = createPerson();
// when
operations.bulkIndex(indexQueries,
IndexCoordinates.of("test-index-person-multiple-level-nested").withTypes("user"));
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-person-multiple-level-nested"));
// then
Map<String, Object> mapping = operations.indexOps(PersonMultipleLevelNested.class).getMapping();
@ -178,7 +176,7 @@ public class NestedObjectTests {
List<IndexQuery> indexQueries = createPerson();
// when
IndexCoordinates index = IndexCoordinates.of("test-index-person-multiple-level-nested").withTypes("user");
IndexCoordinates index = IndexCoordinates.of("test-index-person-multiple-level-nested");
operations.bulkIndex(indexQueries, index);
operations.indexOps(PersonMultipleLevelNested.class).refresh();
@ -318,7 +316,7 @@ public class NestedObjectTests {
indexQueries.add(indexQuery1);
indexQueries.add(indexQuery2);
IndexCoordinates index = IndexCoordinates.of("test-index-person").withTypes("user");
IndexCoordinates index = IndexCoordinates.of("test-index-person");
operations.bulkIndex(indexQueries, index);
operations.indexOps(Person.class).refresh();
@ -367,7 +365,7 @@ public class NestedObjectTests {
indexQueries.add(indexQuery2);
// when
IndexCoordinates index = IndexCoordinates.of("test-index-book-nested-objects").withTypes("book");
IndexCoordinates index = IndexCoordinates.of("test-index-book-nested-objects");
operations.bulkIndex(indexQueries, index);
operations.indexOps(Book.class).refresh();

View File

@ -110,9 +110,8 @@ public abstract class ElasticsearchTemplateTests {
private static final String INDEX_1_NAME = "test-index-1";
private static final String INDEX_2_NAME = "test-index-2";
private static final String INDEX_3_NAME = "test-index-3";
private static final String TYPE_NAME = "test-type";
protected final IndexCoordinates index = IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY).withTypes(TYPE_NAME);
protected final IndexCoordinates index = IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY);
@Autowired protected ElasticsearchOperations operations;
private IndexOperations indexOperations;
@ -383,7 +382,7 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery idxQuery = new IndexQueryBuilder().withId(sampleEntity.getId()).withObject(sampleEntity).build();
operations.index(idxQuery, IndexCoordinates.of(INDEX_1_NAME).withTypes("test-type"));
operations.index(idxQuery, IndexCoordinates.of(INDEX_1_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
@ -541,17 +540,17 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery idxQuery1 = new IndexQueryBuilder().withId(randomNumeric(5)).withObject(sampleEntity).build();
operations.index(idxQuery1, IndexCoordinates.of(INDEX_1_NAME).withTypes("test-type"));
operations.index(idxQuery1, IndexCoordinates.of(INDEX_1_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
IndexQuery idxQuery2 = new IndexQueryBuilder().withId(randomNumeric(5)).withObject(sampleEntity).build();
operations.index(idxQuery2, IndexCoordinates.of(INDEX_2_NAME).withTypes("test-type"));
operations.index(idxQuery2, IndexCoordinates.of(INDEX_2_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
// when
Query query = new NativeSearchQueryBuilder().withQuery(termQuery("message", "foo")).build();
operations.delete(query, SampleEntity.class, IndexCoordinates.of("test-index-*").withTypes(TYPE_NAME));
operations.delete(query, SampleEntity.class, IndexCoordinates.of("test-index-*"));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
@ -573,18 +572,18 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery idxQuery1 = new IndexQueryBuilder().withId(randomNumeric(5)).withObject(sampleEntity).build();
operations.index(idxQuery1, IndexCoordinates.of(INDEX_1_NAME).withTypes("test-type"));
operations.index(idxQuery1, IndexCoordinates.of(INDEX_1_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
IndexQuery idxQuery2 = new IndexQueryBuilder().withId(randomNumeric(5)).withObject(sampleEntity).build();
operations.index(idxQuery2, IndexCoordinates.of(INDEX_2_NAME).withTypes("test-type"));
operations.index(idxQuery2, IndexCoordinates.of(INDEX_2_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
// when
Query query = new NativeSearchQueryBuilder().withQuery(termQuery("message", "negative")).build();
operations.delete(query, SampleEntity.class, IndexCoordinates.of("test-index-*").withTypes(TYPE_NAME));
operations.delete(query, SampleEntity.class, IndexCoordinates.of("test-index-*"));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
@ -1568,7 +1567,7 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery idxQuery = new IndexQueryBuilder().withId(sampleEntity.getId()).withObject(sampleEntity).build();
IndexCoordinates index = IndexCoordinates.of(INDEX_1_NAME).withTypes("test-type");
IndexCoordinates index = IndexCoordinates.of(INDEX_1_NAME);
operations.index(idxQuery, index);
operations.indexOps(index).refresh();
@ -1631,7 +1630,7 @@ public abstract class ElasticsearchTemplateTests {
indexOperations.putMapping(clazz);
bookIndexOperations.refresh();
IndexCoordinates bookIndex = IndexCoordinates.of("test-index-book-core-template").withTypes("book");
IndexCoordinates bookIndex = IndexCoordinates.of("test-index-book-core-template");
operations.index(buildIndex(SampleEntity.builder().id("1").message("ab").build()), index);
operations.index(buildIndex(Book.builder().id("2").description("bc").build()), bookIndex);
@ -1691,7 +1690,7 @@ public abstract class ElasticsearchTemplateTests {
indexQuery.setSource(documentSource);
// when
operations.index(indexQuery, IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY).withTypes(TYPE_NAME));
operations.index(indexQuery, IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY));
indexOperations.refresh();
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(termQuery("id", indexQuery.getId()))
.build();
@ -1711,9 +1710,8 @@ public abstract class ElasticsearchTemplateTests {
indexQuery.setId("2333343434");
// when
assertThatThrownBy(
() -> operations.index(indexQuery, IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY).withTypes(TYPE_NAME)))
.isInstanceOf(ElasticsearchException.class);
assertThatThrownBy(() -> operations.index(indexQuery, IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY)))
.isInstanceOf(ElasticsearchException.class);
}
@Test
@ -1920,7 +1918,7 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery indexQuery = new IndexQueryBuilder().withId(documentId).withObject(sampleEntity).build();
operations.index(indexQuery, IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY).withTypes(TYPE_NAME));
operations.index(indexQuery, IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY));
operations.indexOps(IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY)).refresh();
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
@ -2030,8 +2028,8 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery indexQuery2 = new IndexQueryBuilder().withId(sampleEntity2.getId()).withObject(sampleEntity2).build();
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME).withTypes("test-type"));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME).withTypes("test-type"));
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
@ -2061,8 +2059,8 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery indexQuery2 = new IndexQueryBuilder().withId(sampleEntity2.getId()).withObject(sampleEntity2).build();
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME).withTypes("test-type"));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME).withTypes("test-type"));
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
@ -2131,8 +2129,8 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery indexQuery2 = new IndexQueryBuilder().withId(sampleEntity2.getId()).withObject(sampleEntity2).build();
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME).withTypes("test-type"));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME).withTypes("test-type"));
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
@ -2162,8 +2160,8 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery indexQuery2 = new IndexQueryBuilder().withId(sampleEntity2.getId()).withObject(sampleEntity2).build();
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME).withTypes("test-type"));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME).withTypes("test-type"));
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
@ -2297,8 +2295,8 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery indexQuery2 = new IndexQueryBuilder().withId(sampleEntity2.getId()).withObject(sampleEntity2).build();
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME).withTypes("test-type"));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME).withTypes("test-type"));
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
@ -2325,8 +2323,8 @@ public abstract class ElasticsearchTemplateTests {
IndexQuery indexQuery1 = new IndexQueryBuilder().withId(entity1.getId()).withObject(entity1).build();
IndexQuery indexQuery2 = new IndexQueryBuilder().withId(entity2.getId()).withObject(entity2).build();
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME).withTypes("hetro"));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME).withTypes("hetro"));
operations.index(indexQuery1, IndexCoordinates.of(INDEX_1_NAME));
operations.index(indexQuery2, IndexCoordinates.of(INDEX_2_NAME));
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
@ -2756,7 +2754,7 @@ public abstract class ElasticsearchTemplateTests {
.withObject(entity) //
.build();
operations.index(indexQuery, IndexCoordinates.of(alias1).withTypes(TYPE_NAME));
operations.index(indexQuery, IndexCoordinates.of(alias1));
// then
List<AliasMetaData> aliasMetaData = indexOperations.queryForAlias();
@ -2804,7 +2802,7 @@ public abstract class ElasticsearchTemplateTests {
.withObject(sampleEntity) //
.build();
operations.index(indexQuery, IndexCoordinates.of(alias).withTypes(TYPE_NAME));
operations.index(indexQuery, IndexCoordinates.of(alias));
operations.indexOps(IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY)).refresh();
NativeSearchQuery query = new NativeSearchQueryBuilder() //

View File

@ -39,11 +39,4 @@ class IndexCoordinatesTest {
void cannotBeInitializedWithEmptyIndexNames() {
assertThatThrownBy(() -> IndexCoordinates.of(new String[] {})).isInstanceOf(IllegalArgumentException.class);
}
@Test
void shouldHaveEmptyTypesWhenNotSet() {
IndexCoordinates indexCoordinates = IndexCoordinates.of("test");
assertThat(indexCoordinates.getTypeNames()).isEmpty();
}
}

View File

@ -61,7 +61,7 @@ public class LogEntityTests {
@Import({ ElasticsearchRestTemplateConfiguration.class })
static class Config {}
private final IndexCoordinates index = IndexCoordinates.of("test-index-log-core").withTypes("test-log-type");
private final IndexCoordinates index = IndexCoordinates.of("test-index-log-core");
@Autowired private ElasticsearchOperations operations;
private IndexOperations indexOperations;

View File

@ -49,7 +49,6 @@ import org.elasticsearch.search.sort.SortOrder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.data.annotation.Id;
@ -201,7 +200,7 @@ public class ReactiveElasticsearchTemplateTests {
Map<String, Object> map = new LinkedHashMap<>(Collections.singletonMap("foo", "bar"));
template.save(map, IndexCoordinates.of(ALTERNATE_INDEX).withTypes("singleton-map")) //
template.save(map, IndexCoordinates.of(ALTERNATE_INDEX)) //
.as(StepVerifier::create) //
.consumeNextWith(actual -> {
assertThat(map).containsKey("id");
@ -218,7 +217,7 @@ public class ReactiveElasticsearchTemplateTests {
@Test // DATAES-519, DATAES-767, DATAES-822
public void getByIdShouldErrorWhenIndexDoesNotExist() {
template.get("foo", SampleEntity.class, IndexCoordinates.of("no-such-index").withTypes("test-type")) //
template.get("foo", SampleEntity.class, IndexCoordinates.of("no-such-index")) //
.as(StepVerifier::create) //
.expectError(ElasticsearchStatusException.class);
}
@ -276,8 +275,8 @@ public class ReactiveElasticsearchTemplateTests {
IndexQuery indexQuery = getIndexQuery(sampleEntity);
IndexCoordinates defaultIndex = IndexCoordinates.of(DEFAULT_INDEX).withTypes("test-type");
IndexCoordinates alternateIndex = IndexCoordinates.of(ALTERNATE_INDEX).withTypes("test-type");
IndexCoordinates defaultIndex = IndexCoordinates.of(DEFAULT_INDEX);
IndexCoordinates alternateIndex = IndexCoordinates.of(ALTERNATE_INDEX);
restTemplate.index(indexQuery, alternateIndex);
indexOperations.refresh();
@ -524,7 +523,8 @@ public class ReactiveElasticsearchTemplateTests {
@Test // DATAES-567, DATAES-767
public void aggregateShouldErrorWhenIndexDoesNotExist() {
template.aggregate(new CriteriaQuery(Criteria.where("message").is("some message")), SampleEntity.class,
template
.aggregate(new CriteriaQuery(Criteria.where("message").is("some message")), SampleEntity.class,
IndexCoordinates.of("no-such-index")) //
.as(StepVerifier::create) //
.expectError(ElasticsearchStatusException.class);
@ -588,7 +588,7 @@ public class ReactiveElasticsearchTemplateTests {
SampleEntity sampleEntity = randomEntity("test message");
index(sampleEntity);
template.delete(sampleEntity.getId(), IndexCoordinates.of(DEFAULT_INDEX).withTypes("test-type")) //
template.delete(sampleEntity.getId(), IndexCoordinates.of(DEFAULT_INDEX)) //
.as(StepVerifier::create)//
.expectNext(sampleEntity.getId()) //
.verifyComplete();
@ -1001,7 +1001,7 @@ public class ReactiveElasticsearchTemplateTests {
private void index(SampleEntity... entities) {
IndexCoordinates indexCoordinates = IndexCoordinates.of(DEFAULT_INDEX).withTypes("test-type");
IndexCoordinates indexCoordinates = IndexCoordinates.of(DEFAULT_INDEX);
if (entities.length == 1) {
restTemplate.index(getIndexQuery(entities[0]), indexCoordinates);

View File

@ -24,7 +24,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@ -56,6 +55,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.ScriptedField;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.Criteria;
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
import org.springframework.data.elasticsearch.core.query.Query;
@ -71,7 +71,7 @@ public class ReactiveElasticsearchTemplateUnitTests {
@Mock ReactiveElasticsearchClient client;
ReactiveElasticsearchTemplate template;
private IndexCoordinates index = IndexCoordinates.of("index").withTypes("type");
private IndexCoordinates index = IndexCoordinates.of("index");
@BeforeEach
public void setUp() {
@ -258,8 +258,7 @@ public class ReactiveElasticsearchTemplateUnitTests {
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "test-index-sample-core-reactive-template-Unit", replicas = 0,
refreshInterval = "-1")
@Document(indexName = "test-index-sample-core-reactive-template-Unit", replicas = 0, refreshInterval = "-1")
static class SampleEntity {
@Id private String id;

View File

@ -97,7 +97,7 @@ public class ElasticsearchTemplateAggregationTests {
.addAuthor(RIZWAN_IDREES).addPublishedYear(YEAR_2002).addPublishedYear(YEAR_2001).addPublishedYear(YEAR_2000)
.score(40).buildIndex();
IndexCoordinates index = IndexCoordinates.of(INDEX_NAME).withTypes("article");
IndexCoordinates index = IndexCoordinates.of(INDEX_NAME);
operations.index(article1, index);
operations.index(article2, index);
operations.index(article3, index);

View File

@ -108,8 +108,7 @@ public class ElasticsearchTemplateCompletionTests {
indexQueries.add(new AnnotatedCompletionEntityBuilder("4").name("Artur Konczak")
.suggest(new String[] { "Artur", "Konczak" }).buildIndex());
operations.bulkIndex(indexQueries,
IndexCoordinates.of("test-index-annotated-completion").withTypes("annotated-completion-type"));
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-annotated-completion"));
operations.indexOps(AnnotatedCompletionEntity.class).refresh();
}
@ -125,8 +124,7 @@ public class ElasticsearchTemplateCompletionTests {
indexQueries.add(new AnnotatedCompletionEntityBuilder("4").name("Mewes Kochheim4")
.suggest(new String[] { "Mewes Kochheim4" }, Integer.MAX_VALUE).buildIndex());
operations.bulkIndex(indexQueries,
IndexCoordinates.of("test-index-annotated-completion").withTypes("annotated-completion-type"));
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-annotated-completion"));
operations.indexOps(AnnotatedCompletionEntity.class).refresh();
}
@ -142,7 +140,7 @@ public class ElasticsearchTemplateCompletionTests {
// when
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
IndexCoordinates.of("test-index-core-completion").withTypes("completion-type"));
IndexCoordinates.of("test-index-core-completion"));
CompletionSuggestion completionSuggestion = suggestResponse.getSuggest().getSuggestion("test-suggest");
List<CompletionSuggestion.Entry.Option> options = completionSuggestion.getEntries().get(0).getOptions();
@ -170,7 +168,7 @@ public class ElasticsearchTemplateCompletionTests {
// when
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
IndexCoordinates.of("test-index-annotated-completion").withTypes("annotated-completion-type"));
IndexCoordinates.of("test-index-annotated-completion"));
CompletionSuggestion completionSuggestion = suggestResponse.getSuggest().getSuggestion("test-suggest");
List<CompletionSuggestion.Entry.Option> options = completionSuggestion.getEntries().get(0).getOptions();
@ -191,7 +189,7 @@ public class ElasticsearchTemplateCompletionTests {
// when
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
IndexCoordinates.of("test-index-annotated-completion").withTypes("annotated-completion-type"));
IndexCoordinates.of("test-index-annotated-completion"));
CompletionSuggestion completionSuggestion = suggestResponse.getSuggest().getSuggestion("test-suggest");
List<CompletionSuggestion.Entry.Option> options = completionSuggestion.getEntries().get(0).getOptions();

View File

@ -110,8 +110,7 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
indexQueries.add(new ContextCompletionEntityBuilder("4").name("Artur Konczak")
.suggest(new String[] { "Artur", "Konczak" }, context4).buildIndex());
operations.bulkIndex(indexQueries,
IndexCoordinates.of("test-index-context-completion").withTypes("context-completion-type"));
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-context-completion"));
operations.indexOps(ContextCompletionEntity.class).refresh();
}
@ -137,7 +136,7 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
// when
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
IndexCoordinates.of("test-index-context-completion").withTypes("context-completion-type"));
IndexCoordinates.of("test-index-context-completion"));
assertThat(suggestResponse.getSuggest()).isNotNull();
CompletionSuggestion completionSuggestion = suggestResponse.getSuggest().getSuggestion("test-suggest");
List<CompletionSuggestion.Entry.Option> options = completionSuggestion.getEntries().get(0).getOptions();
@ -169,7 +168,7 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
// when
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
IndexCoordinates.of("test-index-context-completion").withTypes("context-completion-type"));
IndexCoordinates.of("test-index-context-completion"));
assertThat(suggestResponse.getSuggest()).isNotNull();
CompletionSuggestion completionSuggestion = suggestResponse.getSuggest().getSuggestion("test-suggest");
List<CompletionSuggestion.Entry.Option> options = completionSuggestion.getEntries().get(0).getOptions();
@ -201,7 +200,7 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
// when
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
IndexCoordinates.of("test-index-context-completion").withTypes("context-completion-type"));
IndexCoordinates.of("test-index-context-completion"));
assertThat(suggestResponse.getSuggest()).isNotNull();
CompletionSuggestion completionSuggestion = suggestResponse.getSuggest().getSuggestion("test-suggest");
List<CompletionSuggestion.Entry.Option> options = completionSuggestion.getEntries().get(0).getOptions();

View File

@ -897,7 +897,7 @@ public class MappingElasticsearchConverterUnitTests {
@AllArgsConstructor
@Builder
@org.springframework.data.elasticsearch.annotations.Document(indexName = "test-index-geo-core-entity-mapper",
type = "geo-test-index", replicas = 0, refreshInterval = "-1")
replicas = 0, refreshInterval = "-1")
static class GeoEntity {
@Id private String id;

View File

@ -71,10 +71,8 @@ public class ElasticsearchTemplateGeoTests {
@Import({ ElasticsearchRestTemplateConfiguration.class })
static class Config {}
private final IndexCoordinates locationMarkerIndex = IndexCoordinates.of("test-index-location-marker-core-geo")
.withTypes("geo-annotation-point-type");
private final IndexCoordinates authorMarkerIndex = IndexCoordinates.of("test-index-author-marker-core-geo")
.withTypes("geo-class-point-type");
private final IndexCoordinates locationMarkerIndex = IndexCoordinates.of("test-index-location-marker-core-geo");
private final IndexCoordinates authorMarkerIndex = IndexCoordinates.of("test-index-author-marker-core-geo");
@Autowired private ElasticsearchOperations operations;

View File

@ -149,7 +149,7 @@ public class MappingBuilderTests extends MappingContextBaseTests {
double price = 2.34;
String id = "abc";
IndexCoordinates index = IndexCoordinates.of("test-index-stock-mapping-builder").withTypes("price");
IndexCoordinates index = IndexCoordinates.of("test-index-stock-mapping-builder");
operations.index(buildIndex(StockPrice.builder() //
.id(id) //
.symbol(symbol) //
@ -192,7 +192,7 @@ public class MappingBuilderTests extends MappingContextBaseTests {
@Test // DATAES-76
public void shouldAddSampleInheritedEntityDocumentToIndex() {
// given
IndexCoordinates index = IndexCoordinates.of("test-index-sample-inherited-mapping-builder").withTypes("mapping");
IndexCoordinates index = IndexCoordinates.of("test-index-sample-inherited-mapping-builder");
IndexOperations indexOps = operations.indexOps(index);
// when

View File

@ -64,7 +64,7 @@ public class CriteriaQueryTests {
@Import({ ElasticsearchRestTemplateConfiguration.class })
static class Config {}
private final IndexCoordinates index = IndexCoordinates.of("test-index-sample-core-query").withTypes("test-type");
private final IndexCoordinates index = IndexCoordinates.of("test-index-sample-core-query");
@Autowired private ElasticsearchOperations operations;
private IndexOperations indexOperations;

View File

@ -116,8 +116,7 @@ public class DynamicSettingAndMappingEntityRepositoryTests {
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(QueryBuilders.termQuery("email", dynamicSettingAndMappingEntity1.getEmail())).build();
IndexCoordinates index = IndexCoordinates.of("test-index-dynamic-setting-and-mapping")
.withTypes("test-setting-type");
IndexCoordinates index = IndexCoordinates.of("test-index-dynamic-setting-and-mapping");
long count = operations.count(searchQuery, DynamicSettingAndMappingEntity.class, index);
SearchHits<DynamicSettingAndMappingEntity> entityList = operations.search(searchQuery,
DynamicSettingAndMappingEntity.class, index);

View File

@ -91,7 +91,7 @@ public class SynonymRepositoryTests {
SearchHits<SynonymEntity> synonymEntities = operations.search(
new NativeSearchQueryBuilder().withQuery(QueryBuilders.termQuery("text", "british")).build(),
SynonymEntity.class, IndexCoordinates.of("test-index-synonym").withTypes("synonym-type"));
SynonymEntity.class, IndexCoordinates.of("test-index-synonym"));
assertThat(synonymEntities).hasSize(1);
}