Skip to content

Commit

Permalink
Merge pull request #109 from swisscomeventandmedia/bugfix/multi-field…
Browse files Browse the repository at this point in the history
…s-mapping

Bugfix: multi fields mapping
  • Loading branch information
kitsunet authored Mar 27, 2023
2 parents b592a9b + 31303b4 commit d9ea76c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Classes/Annotations/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion Classes/Mapping/EntityMappingBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d9ea76c

Please sign in to comment.