Fix meta field mapping when computing fields for projections.
Related to: #3894
This commit is contained in:
@@ -302,6 +302,7 @@ class QueryOperations {
|
||||
mappedFields = queryMapper.getMappedFields(fields, entity);
|
||||
} else {
|
||||
mappedFields = propertyOperations.computeMappedFieldsForProjection(projection, fields);
|
||||
mappedFields = queryMapper.addMetaAttributes(mappedFields, entity);
|
||||
}
|
||||
|
||||
if (entity.hasTextScoreProperty() && mappedFields.containsKey(entity.getTextScoreProperty().getFieldName())
|
||||
|
||||
@@ -240,6 +240,18 @@ public class QueryMapper {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds missing {@code $meta} representation if required.
|
||||
*
|
||||
* @param source must not be {@literal null}.
|
||||
* @param entity can be {@literal null}.
|
||||
* @return never {@literal null}.
|
||||
* @since 3.4
|
||||
*/
|
||||
public Document addMetaAttributes(Document source, @Nullable MongoPersistentEntity<?> entity) {
|
||||
return mapMetaAttributes(source, entity, MetaMapping.FORCE);
|
||||
}
|
||||
|
||||
private Document mapMetaAttributes(Document source, @Nullable MongoPersistentEntity<?> entity,
|
||||
MetaMapping metaMapping) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user