Skip to content

Commit d9ea76c

Browse files
authored
Merge pull request #109 from swisscomeventandmedia/bugfix/multi-fields-mapping
Bugfix: multi fields mapping
2 parents b592a9b + 31303b4 commit d9ea76c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Classes/Annotations/Mapping.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ final class Mapping
134134
public function getPropertiesArray()
135135
{
136136
$properties = get_object_vars($this);
137+
138+
// Remove unsupported ES mapping properties. These properties are used internally only.
137139
unset($properties['fields']);
140+
unset($properties['index_name']);
138141

139142
return $properties;
140143
}

Classes/Mapping/EntityMappingBuilder.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ protected function augmentMappingByProperty(Mapping $mapping, string $className,
131131
if (isset($multiFields[$multiFieldIndexName])) {
132132
throw new ElasticSearchException('Duplicate index name in the same multi field is not allowed "' . $className . '::' . $propertyName . '".');
133133
}
134-
$multiFieldAnnotation->type = $mappingType;
134+
if (!$multiFieldAnnotation->type) {
135+
// Fallback to the parent's type if not specified on multi-field
136+
$multiFieldAnnotation->type = $mappingType;
137+
}
135138
$multiFields[$multiFieldIndexName] = $this->processMappingAnnotation($multiFieldAnnotation);
136139
}
137140
$mapping->setPropertyByPath([$propertyName, 'fields'], $multiFields);

0 commit comments

Comments
 (0)