mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-22 20:12:11 +00:00
Add excludeFromSource handling to multifield.
Original Pull Request #2975 Closes #2971 (cherry picked from commit 555b5702467a904ecd40bac486d3ba4bdb71a744) (cherry picked from commit a179dd06431ce7457d24c13902ba65477f7a92af)
This commit is contained in:
parent
74b05d21b5
commit
5a2dcd3b01
@ -334,8 +334,10 @@ public class MappingBuilder {
|
||||
: nestedPropertyPrefix + '.' + property.getFieldName();
|
||||
|
||||
Field fieldAnnotation = property.findAnnotation(Field.class);
|
||||
MultiField multiFieldAnnotation = property.findAnnotation(MultiField.class);
|
||||
|
||||
if (fieldAnnotation != null && fieldAnnotation.excludeFromSource()) {
|
||||
if ((fieldAnnotation != null && fieldAnnotation.excludeFromSource()) ||
|
||||
multiFieldAnnotation != null && multiFieldAnnotation.mainField().excludeFromSource()) {
|
||||
excludeFromSource.add(nestedPropertyPath);
|
||||
}
|
||||
|
||||
@ -366,8 +368,6 @@ public class MappingBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
MultiField multiField = property.findAnnotation(MultiField.class);
|
||||
|
||||
if (isCompletionProperty) {
|
||||
CompletionField completionField = property.findAnnotation(CompletionField.class);
|
||||
applyCompletionFieldMapping(propertiesNode, property, completionField);
|
||||
@ -375,8 +375,8 @@ public class MappingBuilder {
|
||||
|
||||
if (isRootObject && fieldAnnotation != null && property.isIdProperty()) {
|
||||
applyDefaultIdFieldMapping(propertiesNode, property);
|
||||
} else if (multiField != null) {
|
||||
addMultiFieldMapping(propertiesNode, property, multiField, isNestedOrObjectProperty, dynamicMapping);
|
||||
} else if (multiFieldAnnotation != null) {
|
||||
addMultiFieldMapping(propertiesNode, property, multiFieldAnnotation, isNestedOrObjectProperty, dynamicMapping);
|
||||
} else if (fieldAnnotation != null) {
|
||||
addSingleFieldMapping(propertiesNode, property, fieldAnnotation, isNestedOrObjectProperty, dynamicMapping);
|
||||
}
|
||||
|
@ -1117,15 +1117,26 @@ public class MappingBuilderUnitTests extends MappingContextBaseTests {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"excluded-multifield": {
|
||||
"type": "text",
|
||||
"fields": {
|
||||
"keyword": {
|
||||
"type": "keyword"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"_source": {
|
||||
"excludes": [
|
||||
"excluded-date",
|
||||
"nestedEntity.excluded-text"
|
||||
"nestedEntity.excluded-text",
|
||||
"excluded-multifield"
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
"""; //
|
||||
|
||||
String mapping = getMappingBuilder().buildPropertyMapping(ExcludedFieldEntity.class);
|
||||
@ -2367,6 +2378,10 @@ public class MappingBuilderUnitTests extends MappingContextBaseTests {
|
||||
excludeFromSource = true) private LocalDate excludedDate;
|
||||
@Nullable
|
||||
@Field(type = Nested) private NestedExcludedFieldEntity nestedEntity;
|
||||
@Nullable
|
||||
@MultiField(mainField = @Field(name = "excluded-multifield", type = Text, excludeFromSource = true), otherFields = {
|
||||
@InnerField(suffix = "keyword", type = Keyword)
|
||||
}) private String excludedMultifield;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
Loading…
x
Reference in New Issue
Block a user