Skip to content

Commit ea98ef4

Browse files
authored
DATAES-874 - Deprecate parent-id related methods and fields.
Original PR: spring-projects#488
1 parent 7d8bc81 commit ea98ef4

File tree

12 files changed

+33
-29
lines changed

12 files changed

+33
-29
lines changed

src/main/asciidoc/reference/elasticsearch-migration-guide-4.0-4.1.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ They do the same, but `putMapping` is consistent with the naming in the Elastics
1818
.Alias handling
1919
In the `IndexOperations` interface the methods `addAlias(AliasQuery)`, `removeAlias(AliasQuery)` and `queryForAlias()` have been deprecated. The new methods `alias(AliasAction)`, `getAliases(String...)` and `getAliasesForIndex(String...)` offer more functionality and a cleaner API.
2020

21+
.Parent-ID
22+
Usage of a parent-id has been removed from Elasticsearch since version 6. We now deprecate the corresponding fields and methods.
23+
2124
[[elasticsearch-migration-guide-4.0-4.1.removal]]
2225
== Removals
2326

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
* Parent
2424
*
2525
* @author Philipp Jardas
26+
* @deprecated since 4.1, not supported anymore by Elasticsearch
2627
*/
27-
28+
@Deprecated
2829
@Persistent
2930
@Inherited
3031
@Retention(RetentionPolicy.RUNTIME)

src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,18 @@ interface AdaptibleEntity<T> extends Entity<T> {
235235
* Returns whether the entity has a parent.
236236
*
237237
* @return {@literal true} if the entity has a parent that has an {@literal id}.
238+
* @deprecated since 4.1, not supported anymore by Elasticsearch
238239
*/
240+
@Deprecated
239241
boolean hasParent();
240242

241243
/**
242244
* Returns the parent Id. Can be {@literal null}.
243245
*
244246
* @return can be {@literal null}.
247+
* @deprecated since 4.1, not supported anymore by Elasticsearch
245248
*/
249+
@Deprecated
246250
@Nullable
247251
Object getParentId();
248252

@@ -589,6 +593,7 @@ public boolean hasParent() {
589593
* (non-Javadoc)
590594
* @see org.springframework.data.elasticsearch.core.EntityOperations.AdaptibleEntity#getParentId()
591595
*/
596+
@Deprecated
592597
@Override
593598
public Object getParentId() {
594599

src/main/java/org/springframework/data/elasticsearch/core/index/MappingBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class MappingBuilder {
7878

7979
private static final String FIELD_INDEX = "index";
8080
private static final String FIELD_PROPERTIES = "properties";
81-
private static final String FIELD_PARENT = "_parent";
81+
@Deprecated private static final String FIELD_PARENT = "_parent";
8282
private static final String FIELD_CONTEXT_NAME = "name";
8383
private static final String FIELD_CONTEXT_TYPE = "type";
8484
private static final String FIELD_CONTEXT_PATH = "path";

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,17 @@ public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, El
5353
@Override
5454
ElasticsearchPersistentProperty getVersionProperty();
5555

56+
/**
57+
* @deprecated since 4.1, not supported anymore by Elasticsearch
58+
*/
59+
@Deprecated
5660
@Nullable
5761
String getParentType();
5862

63+
/**
64+
* @deprecated since 4.1, not supported anymore by Elasticsearch
65+
*/
66+
@Deprecated
5967
@Nullable
6068
ElasticsearchPersistentProperty getParentIdProperty();
6169

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public interface ElasticsearchPersistentProperty extends PersistentProperty<Elas
6262
*
6363
* @return
6464
* @since 3.1
65+
* @deprecated since 4.1, not supported anymore by Elasticsearch
6566
*/
67+
@Deprecated
6668
boolean isParentProperty();
6769

6870
/**

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
6363
private short replicas;
6464
private @Nullable String refreshInterval;
6565
private @Nullable String indexStoreType;
66-
private @Nullable String parentType;
67-
private @Nullable ElasticsearchPersistentProperty parentIdProperty;
66+
@Deprecated private @Nullable String parentType;
67+
@Deprecated private @Nullable ElasticsearchPersistentProperty parentIdProperty;
6868
private @Nullable ElasticsearchPersistentProperty scoreProperty;
6969
private @Nullable ElasticsearchPersistentProperty seqNoPrimaryTermProperty;
7070
private @Nullable String settingPath;
@@ -135,12 +135,14 @@ public String getRefreshInterval() {
135135

136136
@Nullable
137137
@Override
138+
@Deprecated
138139
public String getParentType() {
139140
return parentType;
140141
}
141142

142143
@Nullable
143144
@Override
145+
@Deprecated
144146
public ElasticsearchPersistentProperty getParentIdProperty() {
145147
return parentIdProperty;
146148
}

src/main/java/org/springframework/data/elasticsearch/core/query/IndexQuery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class IndexQuery {
3131
@Nullable private Object object;
3232
@Nullable private Long version;
3333
@Nullable private String source;
34-
@Nullable private String parentId;
34+
@Deprecated @Nullable private String parentId;
3535
@Nullable private Long seqNo;
3636
@Nullable private Long primaryTerm;
3737

src/main/java/org/springframework/data/elasticsearch/core/query/IndexQueryBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class IndexQueryBuilder {
3131
@Nullable private Object object;
3232
@Nullable private Long version;
3333
@Nullable private String source;
34-
@Nullable private String parentId;
34+
@Deprecated @Nullable private String parentId;
3535
@Nullable private Long seqNo;
3636
@Nullable private Long primaryTerm;
3737

@@ -55,6 +55,7 @@ public IndexQueryBuilder withSource(String source) {
5555
return this;
5656
}
5757

58+
@Deprecated
5859
public IndexQueryBuilder withParentId(String parentId) {
5960
this.parentId = parentId;
6061
return this;

src/main/java/org/springframework/data/elasticsearch/repository/support/ElasticsearchEntityInformation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public interface ElasticsearchEntityInformation<T, ID> extends EntityInformation
4242
@Nullable
4343
VersionType getVersionType();
4444

45+
/**
46+
* @deprecated since 4.1, not supported anymore by Elasticsearch
47+
*/
48+
@Deprecated
4549
@Nullable
4650
String getParentId(T entity);
4751
}

src/main/java/org/springframework/data/elasticsearch/repository/support/MappingElasticsearchEntityInformation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public VersionType getVersionType() {
7474
return persistentEntity.getVersionType();
7575
}
7676

77+
@Deprecated
7778
@Override
7879
public String getParentId(T entity) {
7980

src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderTests.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,6 @@ public void shouldAddStockPriceDocumentToIndex() {
169169
assertThat(entry.getPrice()).isCloseTo(BigDecimal.valueOf(price), Percentage.withPercentage(0.01));
170170
}
171171

172-
@Test // DATAES-568
173-
public void shouldCreateMappingForSpecifiedParentType() throws JSONException {
174-
175-
String expected = "{\"_parent\":{\"type\":\"parentType\"},\"properties\":{}}";
176-
177-
String mapping = getMappingBuilder().buildPropertyMapping(MinimalChildEntity.class);
178-
179-
assertEquals(expected, mapping, false);
180-
}
181-
182172
@Test // DATAES-76
183173
public void shouldBuildMappingWithSuperclass() throws JSONException {
184174

@@ -668,19 +658,6 @@ static class MultiFieldEntity {
668658
}
669659
}
670660

671-
/**
672-
* MinimalChildEntity
673-
*
674-
* @author Peter-Josef Meisch
675-
*/
676-
@Document(indexName = "test-index-minimal")
677-
static class MinimalChildEntity {
678-
679-
@Nullable @Id private String id;
680-
681-
@Nullable @Parent(type = "parentType") private String parentId;
682-
}
683-
684661
/**
685662
* @author Rizwan Idrees
686663
* @author Mohsin Husen

0 commit comments

Comments
 (0)