Allow empty or null or no mappings: key under type configuration

refs #300. This commit allow to define types without having to
set any mapping as Elasticsearch build his own.

The minimal config become:

    indexes:
        toto:
            client: default
            types:
                Article:
                    mappings: ~
                    ...
This commit is contained in:
Damien Alexandre 2013-11-29 14:59:56 +01:00
parent b149ac235b
commit 2862259d8e
2 changed files with 10 additions and 1 deletions

View file

@ -432,6 +432,10 @@ class Configuration implements ConfigurationInterface
}
foreach ($index['types'] as $type) {
if (empty($type['mappings'])) {
continue;
}
$nestings = array_merge_recursive($nestings, $this->getNestingsForType($type['mappings'], $nestings));
}
}

View file

@ -199,6 +199,11 @@ class FOSElasticaExtension extends Extension
$typeDef->addMethodCall('setSerializer', array(array(new Reference($callbackId), 'serialize')));
}
$container->setDefinition($typeId, $typeDef);
$this->indexConfigs[$indexName]['config']['mappings'][$name] = array(
"_source" => array("enabled" => true), // Add a default setting for empty mapping settings
);
if (isset($type['_id'])) {
$this->indexConfigs[$indexName]['config']['mappings'][$name]['_id'] = $type['_id'];
}
@ -211,7 +216,7 @@ class FOSElasticaExtension extends Extension
if (isset($type['_routing'])) {
$this->indexConfigs[$indexName]['config']['mappings'][$name]['_routing'] = $type['_routing'];
}
if (isset($type['mappings'])) {
if (isset($type['mappings']) && !empty($type['mappings'])) {
$this->indexConfigs[$indexName]['config']['mappings'][$name]['properties'] = $type['mappings'];
$typeName = sprintf('%s/%s', $indexName, $name);
$this->typeFields[$typeName] = $type['mappings'];