Skip to content

Commit 0f84158

Browse files
authored
DATAES-841 - Remove deprecated type mappings code.
Original PR: spring-projects#468
1 parent dc6734d commit 0f84158

21 files changed

+80
-142
lines changed

src/main/asciidoc/preface.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ You will notice similarities to the Spring data solr and mongodb support in the
1010

1111
include::reference/elasticsearch-new.adoc[leveloffset=+1]
1212
include::reference/elasticsearch-migration-guide-3.2-4.0.adoc[leveloffset=+1]
13+
include::reference/elasticsearch-migration-guide-4.0-4.1.adoc[leveloffset=+1]
1314

1415
[[preface.metadata]]
1516
== Project Metadata
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[[elasticsearch-migration-guide-4.0-4.1]]
2+
== Upgrading from 4.0.x to 4.1.x
3+
4+
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.
5+
6+
=== Removals
7+
8+
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.
9+

src/main/java/org/springframework/data/elasticsearch/annotations/Document.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@
5353
*/
5454
String indexName();
5555

56-
/**
57-
* Mapping type name. <br/>
58-
* deprecated as Elasticsearch does not support this anymore
59-
* (@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
60-
* Elasticsearch 8.
61-
*
62-
* @deprecated since 4.0
63-
*/
64-
@Deprecated
65-
String type() default "";
66-
6756
/**
6857
* Use server-side settings when creating the index.
6958
*/

src/main/java/org/springframework/data/elasticsearch/core/mapping/IndexCoordinates.java

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.util.Arrays;
1919

20-
import org.springframework.lang.Nullable;
2120
import org.springframework.util.Assert;
2221

2322
/**
@@ -34,29 +33,15 @@ public class IndexCoordinates {
3433
public static final String TYPE = "_doc";
3534

3635
private final String[] indexNames;
37-
private final String[] typeNames;
3836

3937
public static IndexCoordinates of(String... indexNames) {
4038
Assert.notNull(indexNames, "indexNames must not be null");
41-
return new IndexCoordinates(indexNames, null);
39+
return new IndexCoordinates(indexNames);
4240
}
4341

44-
private IndexCoordinates(String[] indexNames, @Nullable String[] typeNames) {
42+
private IndexCoordinates(String[] indexNames) {
4543
Assert.notEmpty(indexNames, "indexNames may not be null or empty");
4644
this.indexNames = indexNames;
47-
this.typeNames = typeNames != null ? typeNames : new String[] {};
48-
}
49-
50-
/**
51-
* Using Index types is deprecated in Elasticsearch.
52-
*
53-
* @param typeNames
54-
* @return
55-
*/
56-
@Deprecated
57-
public IndexCoordinates withTypes(String... typeNames) {
58-
Assert.notEmpty(typeNames, "typeNames must not be null");
59-
return new IndexCoordinates(this.indexNames, typeNames);
6045
}
6146

6247
public String getIndexName() {
@@ -67,20 +52,8 @@ public String[] getIndexNames() {
6752
return Arrays.copyOf(indexNames, indexNames.length);
6853
}
6954

70-
@Deprecated
71-
@Nullable
72-
public String getTypeName() {
73-
return typeNames.length > 0 ? typeNames[0] : null;
74-
}
75-
76-
@Deprecated
77-
public String[] getTypeNames() {
78-
return Arrays.copyOf(typeNames, typeNames.length);
79-
}
80-
8155
@Override
8256
public String toString() {
83-
return "IndexCoordinates{" + "indexNames=" + Arrays.toString(indexNames) + ", typeNames="
84-
+ Arrays.toString(typeNames) + '}';
57+
return "IndexCoordinates{" + "indexNames=" + Arrays.toString(indexNames) + '}';
8558
}
8659
}

src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntity.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
*/
1616
package org.springframework.data.elasticsearch.core.mapping;
1717

18-
import static org.springframework.util.StringUtils.*;
19-
20-
import java.util.Locale;
2118
import java.util.Map;
2219
import java.util.concurrent.ConcurrentHashMap;
2320
import java.util.concurrent.atomic.AtomicReference;
@@ -66,7 +63,6 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
6663
private final SpelExpressionParser parser;
6764

6865
private @Nullable String indexName;
69-
private @Nullable String indexType;
7066
private boolean useServerConfiguration;
7167
private short shards;
7268
private short replicas;
@@ -93,7 +89,6 @@ public SimpleElasticsearchPersistentEntity(TypeInformation<T> typeInformation) {
9389
Assert.hasText(document.indexName(),
9490
" Unknown indexName. Make sure the indexName is defined. e.g @Document(indexName=\"foo\")");
9591
this.indexName = document.indexName();
96-
this.indexType = hasText(document.type()) ? document.type() : clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
9792
this.useServerConfiguration = document.useServerConfiguration();
9893
this.shards = document.shards();
9994
this.replicas = document.replicas();
@@ -124,19 +119,9 @@ private String getIndexName() {
124119
return getTypeInformation().getType().getSimpleName();
125120
}
126121

127-
private String getIndexType() {
128-
129-
if (indexType != null) {
130-
Expression expression = parser.parseExpression(indexType, ParserContext.TEMPLATE_EXPRESSION);
131-
return expression.getValue(context, String.class);
132-
}
133-
134-
return "";
135-
}
136-
137122
@Override
138123
public IndexCoordinates getIndexCoordinates() {
139-
return IndexCoordinates.of(getIndexName()).withTypes(getIndexType());
124+
return IndexCoordinates.of(getIndexName());
140125
}
141126

142127
@Nullable

src/main/java/org/springframework/data/elasticsearch/repository/query/AbstractReactiveElasticsearchRepositoryQuery.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ private Object execute(ElasticsearchParameterAccessor parameterAccessor) {
9090

9191
Class<?> targetType = processor.getReturnedType().getTypeToRead();
9292
String indexName = queryMethod.getEntityInformation().getIndexName();
93-
String indexTypeName = queryMethod.getEntityInformation().getIndexTypeName();
94-
IndexCoordinates index = IndexCoordinates.of(indexName).withTypes(indexTypeName);
93+
IndexCoordinates index = IndexCoordinates.of(indexName);
9594

9695
ReactiveElasticsearchQueryExecution execution = getExecution(parameterAccessor,
9796
new ResultProcessingConverter(processor));

src/test/java/org/springframework/data/elasticsearch/NestedObjectTests.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void shouldIndexInitialLevelNestedObject() {
121121
indexQueries.add(indexQuery1);
122122
indexQueries.add(indexQuery2);
123123

124-
IndexCoordinates index = IndexCoordinates.of("test-index-person").withTypes("user");
124+
IndexCoordinates index = IndexCoordinates.of("test-index-person");
125125
operations.bulkIndex(indexQueries, index);
126126
operations.indexOps(Person.class).refresh();
127127

@@ -141,13 +141,12 @@ public void shouldIndexMultipleLevelNestedObject() {
141141
List<IndexQuery> indexQueries = createPerson();
142142

143143
// when
144-
operations.bulkIndex(indexQueries,
145-
IndexCoordinates.of("test-index-person-multiple-level-nested").withTypes("user"));
144+
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-person-multiple-level-nested"));
146145
operations.indexOps(PersonMultipleLevelNested.class).refresh();
147146

148147
// then
149148
PersonMultipleLevelNested personIndexed = operations.get("1", PersonMultipleLevelNested.class,
150-
IndexCoordinates.of("test-index-person-multiple-level-nested").withTypes("user"));
149+
IndexCoordinates.of("test-index-person-multiple-level-nested"));
151150
assertThat(personIndexed).isNotNull();
152151
}
153152

@@ -158,8 +157,7 @@ public void shouldIndexMultipleLevelNestedObjectWithIncludeInParent() {
158157
List<IndexQuery> indexQueries = createPerson();
159158

160159
// when
161-
operations.bulkIndex(indexQueries,
162-
IndexCoordinates.of("test-index-person-multiple-level-nested").withTypes("user"));
160+
operations.bulkIndex(indexQueries, IndexCoordinates.of("test-index-person-multiple-level-nested"));
163161

164162
// then
165163
Map<String, Object> mapping = operations.indexOps(PersonMultipleLevelNested.class).getMapping();
@@ -178,7 +176,7 @@ public void shouldSearchUsingNestedQueryOnMultipleLevelNestedObject() {
178176
List<IndexQuery> indexQueries = createPerson();
179177

180178
// when
181-
IndexCoordinates index = IndexCoordinates.of("test-index-person-multiple-level-nested").withTypes("user");
179+
IndexCoordinates index = IndexCoordinates.of("test-index-person-multiple-level-nested");
182180
operations.bulkIndex(indexQueries, index);
183181
operations.indexOps(PersonMultipleLevelNested.class).refresh();
184182

@@ -318,7 +316,7 @@ public void shouldSearchBooksForPersonInitialLevelNestedType() {
318316
indexQueries.add(indexQuery1);
319317
indexQueries.add(indexQuery2);
320318

321-
IndexCoordinates index = IndexCoordinates.of("test-index-person").withTypes("user");
319+
IndexCoordinates index = IndexCoordinates.of("test-index-person");
322320
operations.bulkIndex(indexQueries, index);
323321
operations.indexOps(Person.class).refresh();
324322

@@ -367,7 +365,7 @@ public void shouldIndexAndSearchMapAsNestedType() {
367365
indexQueries.add(indexQuery2);
368366

369367
// when
370-
IndexCoordinates index = IndexCoordinates.of("test-index-book-nested-objects").withTypes("book");
368+
IndexCoordinates index = IndexCoordinates.of("test-index-book-nested-objects");
371369
operations.bulkIndex(indexQueries, index);
372370
operations.indexOps(Book.class).refresh();
373371

0 commit comments

Comments
 (0)