-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Allow to customize the mapped type name for @InnerField and @Field annotations #2950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…notations Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
@@ -77,6 +78,12 @@ void cleanup() { | |||
operations.indexOps(IndexCoordinates.of(indexNameProvider.getPrefix() + "*")).delete(); | |||
} | |||
|
|||
@Test | |||
public void shouldSupportAllTypes() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is not strictly related but EntityWithAllTypes
was not used in tests at all, fixing that
@sothawo would really appreciate a review when you have some time, thank you |
tomorrow, been busy this week 😁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, I just think that the mappedName
should be called mappedTypeName
so that it will not be confused with the field name, that is mapped as well from the Java property name to the Field.name
attribute
@@ -240,4 +241,11 @@ | |||
* @since 5.1 | |||
*/ | |||
boolean storeEmptyValue() default true; | |||
|
|||
/** | |||
* overrides the mapping field type which otherwise will be taken from corresponding {@link FieldType} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* overrides the mapping field type which otherwise will be taken from corresponding {@link FieldType} | |
* overrides the field type in the mapping which otherwise will be taken from corresponding {@link FieldType} |
Seems a little clearer for me
@@ -171,4 +172,11 @@ | |||
* @since 5.4 | |||
*/ | |||
KnnIndexOptions[] knnIndexOptions() default {}; | |||
|
|||
/** | |||
* overrides the mapping field type which otherwise will be taken from corresponding {@link FieldType} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
@@ -210,7 +212,7 @@ private void writeTypeHintMapping(ObjectNode propertiesNode) throws IOException | |||
} | |||
|
|||
private void mapEntity(ObjectNode objectNode, @Nullable ElasticsearchPersistentEntity<?> entity, | |||
boolean isRootObject, String nestedObjectFieldName, boolean nestedOrObjectField, FieldType fieldType, | |||
boolean isRootObject, String nestedObjectFieldName, boolean nestedOrObjectField, FieldType fieldType, String mappedName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boolean isRootObject, String nestedObjectFieldName, boolean nestedOrObjectField, FieldType fieldType, String mappedName, | |
boolean isRootObject, String nestedObjectFieldName, boolean nestedOrObjectField, FieldType fieldType, String fieldTypemappedName, |
might be mistaken as as mapped name of the entity
* | ||
* @since 5.4 | ||
*/ | ||
String mappedName() default ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String mappedName() default ""; | |
String mappedTypeName() default ""; |
to not confuse with the field name
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
Thanks a lot for the review @sothawo , comments addressed! Thanks again! |
In Spring Data OpenSearch [1], which is built on top of Spring Data Elasticsearch, we are running into cases where both projects differ in incompatible ways. One of such cases is supported mapping field types (baked by
org.springframework.data.elasticsearch.annotations.FieldType
), for example:would have to become
for OpenSearch.
This pull request adds optional
mappedName
attribute to@InnerField
and@Field
annotations (and model classes respectively), to address the possible divergence, for example:It would require a bit more work for OpenSearch users but not the Elasticsearch ones. The change would be non-breaking (defaults to
""
andFieldType::getMappedType
) and work seamlessly.Closes #2942