DATAES-874 - Deprecate parent-id related methods and fields.

Original PR: #488
This commit is contained in:
Peter-Josef Meisch 2020-06-28 16:48:20 +02:00 committed by GitHub
parent 7d8bc81fdd
commit ea98ef4533
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 33 additions and 29 deletions

View File

@ -18,6 +18,9 @@ They do the same, but `putMapping` is consistent with the naming in the Elastics
.Alias handling .Alias handling
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. 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.
.Parent-ID
Usage of a parent-id has been removed from Elasticsearch since version 6. We now deprecate the corresponding fields and methods.
[[elasticsearch-migration-guide-4.0-4.1.removal]] [[elasticsearch-migration-guide-4.0-4.1.removal]]
== Removals == Removals

View File

@ -23,8 +23,9 @@ import org.springframework.data.annotation.Persistent;
* Parent * Parent
* *
* @author Philipp Jardas * @author Philipp Jardas
* @deprecated since 4.1, not supported anymore by Elasticsearch
*/ */
@Deprecated
@Persistent @Persistent
@Inherited @Inherited
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)

View File

@ -235,14 +235,18 @@ class EntityOperations {
* Returns whether the entity has a parent. * Returns whether the entity has a parent.
* *
* @return {@literal true} if the entity has a parent that has an {@literal id}. * @return {@literal true} if the entity has a parent that has an {@literal id}.
* @deprecated since 4.1, not supported anymore by Elasticsearch
*/ */
@Deprecated
boolean hasParent(); boolean hasParent();
/** /**
* Returns the parent Id. Can be {@literal null}. * Returns the parent Id. Can be {@literal null}.
* *
* @return can be {@literal null}. * @return can be {@literal null}.
* @deprecated since 4.1, not supported anymore by Elasticsearch
*/ */
@Deprecated
@Nullable @Nullable
Object getParentId(); Object getParentId();
@ -589,6 +593,7 @@ class EntityOperations {
* (non-Javadoc) * (non-Javadoc)
* @see org.springframework.data.elasticsearch.core.EntityOperations.AdaptibleEntity#getParentId() * @see org.springframework.data.elasticsearch.core.EntityOperations.AdaptibleEntity#getParentId()
*/ */
@Deprecated
@Override @Override
public Object getParentId() { public Object getParentId() {

View File

@ -78,7 +78,7 @@ public class MappingBuilder {
private static final String FIELD_INDEX = "index"; private static final String FIELD_INDEX = "index";
private static final String FIELD_PROPERTIES = "properties"; private static final String FIELD_PROPERTIES = "properties";
private static final String FIELD_PARENT = "_parent"; @Deprecated private static final String FIELD_PARENT = "_parent";
private static final String FIELD_CONTEXT_NAME = "name"; private static final String FIELD_CONTEXT_NAME = "name";
private static final String FIELD_CONTEXT_TYPE = "type"; private static final String FIELD_CONTEXT_TYPE = "type";
private static final String FIELD_CONTEXT_PATH = "path"; private static final String FIELD_CONTEXT_PATH = "path";

View File

@ -53,9 +53,17 @@ public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, El
@Override @Override
ElasticsearchPersistentProperty getVersionProperty(); ElasticsearchPersistentProperty getVersionProperty();
/**
* @deprecated since 4.1, not supported anymore by Elasticsearch
*/
@Deprecated
@Nullable @Nullable
String getParentType(); String getParentType();
/**
* @deprecated since 4.1, not supported anymore by Elasticsearch
*/
@Deprecated
@Nullable @Nullable
ElasticsearchPersistentProperty getParentIdProperty(); ElasticsearchPersistentProperty getParentIdProperty();

View File

@ -62,7 +62,9 @@ public interface ElasticsearchPersistentProperty extends PersistentProperty<Elas
* *
* @return * @return
* @since 3.1 * @since 3.1
* @deprecated since 4.1, not supported anymore by Elasticsearch
*/ */
@Deprecated
boolean isParentProperty(); boolean isParentProperty();
/** /**

View File

@ -63,8 +63,8 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
private short replicas; private short replicas;
private @Nullable String refreshInterval; private @Nullable String refreshInterval;
private @Nullable String indexStoreType; private @Nullable String indexStoreType;
private @Nullable String parentType; @Deprecated private @Nullable String parentType;
private @Nullable ElasticsearchPersistentProperty parentIdProperty; @Deprecated private @Nullable ElasticsearchPersistentProperty parentIdProperty;
private @Nullable ElasticsearchPersistentProperty scoreProperty; private @Nullable ElasticsearchPersistentProperty scoreProperty;
private @Nullable ElasticsearchPersistentProperty seqNoPrimaryTermProperty; private @Nullable ElasticsearchPersistentProperty seqNoPrimaryTermProperty;
private @Nullable String settingPath; private @Nullable String settingPath;
@ -135,12 +135,14 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
@Nullable @Nullable
@Override @Override
@Deprecated
public String getParentType() { public String getParentType() {
return parentType; return parentType;
} }
@Nullable @Nullable
@Override @Override
@Deprecated
public ElasticsearchPersistentProperty getParentIdProperty() { public ElasticsearchPersistentProperty getParentIdProperty() {
return parentIdProperty; return parentIdProperty;
} }

View File

@ -31,7 +31,7 @@ public class IndexQuery {
@Nullable private Object object; @Nullable private Object object;
@Nullable private Long version; @Nullable private Long version;
@Nullable private String source; @Nullable private String source;
@Nullable private String parentId; @Deprecated @Nullable private String parentId;
@Nullable private Long seqNo; @Nullable private Long seqNo;
@Nullable private Long primaryTerm; @Nullable private Long primaryTerm;

View File

@ -31,7 +31,7 @@ public class IndexQueryBuilder {
@Nullable private Object object; @Nullable private Object object;
@Nullable private Long version; @Nullable private Long version;
@Nullable private String source; @Nullable private String source;
@Nullable private String parentId; @Deprecated @Nullable private String parentId;
@Nullable private Long seqNo; @Nullable private Long seqNo;
@Nullable private Long primaryTerm; @Nullable private Long primaryTerm;
@ -55,6 +55,7 @@ public class IndexQueryBuilder {
return this; return this;
} }
@Deprecated
public IndexQueryBuilder withParentId(String parentId) { public IndexQueryBuilder withParentId(String parentId) {
this.parentId = parentId; this.parentId = parentId;
return this; return this;

View File

@ -42,6 +42,10 @@ public interface ElasticsearchEntityInformation<T, ID> extends EntityInformation
@Nullable @Nullable
VersionType getVersionType(); VersionType getVersionType();
/**
* @deprecated since 4.1, not supported anymore by Elasticsearch
*/
@Deprecated
@Nullable @Nullable
String getParentId(T entity); String getParentId(T entity);
} }

View File

@ -74,6 +74,7 @@ public class MappingElasticsearchEntityInformation<T, ID> extends PersistentEnti
return persistentEntity.getVersionType(); return persistentEntity.getVersionType();
} }
@Deprecated
@Override @Override
public String getParentId(T entity) { public String getParentId(T entity) {

View File

@ -169,16 +169,6 @@ public class MappingBuilderTests extends MappingContextBaseTests {
assertThat(entry.getPrice()).isCloseTo(BigDecimal.valueOf(price), Percentage.withPercentage(0.01)); assertThat(entry.getPrice()).isCloseTo(BigDecimal.valueOf(price), Percentage.withPercentage(0.01));
} }
@Test // DATAES-568
public void shouldCreateMappingForSpecifiedParentType() throws JSONException {
String expected = "{\"_parent\":{\"type\":\"parentType\"},\"properties\":{}}";
String mapping = getMappingBuilder().buildPropertyMapping(MinimalChildEntity.class);
assertEquals(expected, mapping, false);
}
@Test // DATAES-76 @Test // DATAES-76
public void shouldBuildMappingWithSuperclass() throws JSONException { public void shouldBuildMappingWithSuperclass() throws JSONException {
@ -668,19 +658,6 @@ public class MappingBuilderTests extends MappingContextBaseTests {
} }
} }
/**
* MinimalChildEntity
*
* @author Peter-Josef Meisch
*/
@Document(indexName = "test-index-minimal")
static class MinimalChildEntity {
@Nullable @Id private String id;
@Nullable @Parent(type = "parentType") private String parentId;
}
/** /**
* @author Rizwan Idrees * @author Rizwan Idrees
* @author Mohsin Husen * @author Mohsin Husen