remove empty fields arrays from mapping, this is not ignored anymore by elasticsearch 1.*

This commit is contained in:
Lea Haensenberger 2014-05-05 11:55:48 +02:00
parent ae02364e7c
commit eaa9f83997

View file

@ -234,6 +234,7 @@ class FOSElasticaExtension extends Extension
$this->indexConfigs[$indexName]['config']['mappings'][$name]['_routing'] = $type['_routing'];
}
if (isset($type['mappings']) && !empty($type['mappings'])) {
$this->cleanUpMapping($type['mappings']);
$this->indexConfigs[$indexName]['config']['mappings'][$name]['properties'] = $type['mappings'];
$typeName = sprintf('%s/%s', $indexName, $name);
$this->typeFields[$typeName] = $type['mappings'];
@ -570,4 +571,14 @@ class FOSElasticaExtension extends Extension
$container->setAlias('fos_elastica.manager', sprintf('fos_elastica.manager.%s', $defaultManagerService));
}
protected function cleanUpMapping(&$mappings)
{
foreach ($mappings as &$fieldProperties)
if (empty($fieldProperties['fields'])) {
unset($fieldProperties['fields']);
} else {
$this->cleanUpMapping($fieldProperties['fields']);
}
}
}