diff --git a/Classes/Annotations/Mapping.php b/Classes/Annotations/Mapping.php index e788c22..6a45e86 100644 --- a/Classes/Annotations/Mapping.php +++ b/Classes/Annotations/Mapping.php @@ -134,7 +134,10 @@ final class Mapping public function getPropertiesArray() { $properties = get_object_vars($this); + + // Remove unsupported ES mapping properties. These properties are used internally only. unset($properties['fields']); + unset($properties['index_name']); return $properties; } diff --git a/Classes/Mapping/EntityMappingBuilder.php b/Classes/Mapping/EntityMappingBuilder.php index 0899c89..114ea23 100644 --- a/Classes/Mapping/EntityMappingBuilder.php +++ b/Classes/Mapping/EntityMappingBuilder.php @@ -131,7 +131,10 @@ protected function augmentMappingByProperty(Mapping $mapping, string $className, if (isset($multiFields[$multiFieldIndexName])) { throw new ElasticSearchException('Duplicate index name in the same multi field is not allowed "' . $className . '::' . $propertyName . '".'); } - $multiFieldAnnotation->type = $mappingType; + if (!$multiFieldAnnotation->type) { + // Fallback to the parent's type if not specified on multi-field + $multiFieldAnnotation->type = $mappingType; + } $multiFields[$multiFieldIndexName] = $this->processMappingAnnotation($multiFieldAnnotation); } $mapping->setPropertyByPath([$propertyName, 'fields'], $multiFields);