diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index a06f209..c971644 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -209,6 +209,7 @@ class Configuration ->end() ->end() ->append($this->getMappingsNode()) + ->append($this->getSourceNode()) ->end() ; @@ -258,4 +259,28 @@ class Configuration return $node; } + + /** + * Returns the array node used for "_source". + */ + protected function getSourceNode() + { + $builder = new TreeBuilder(); + $node = $builder->root('_source'); + + $node + ->children() + ->arrayNode('excludes') + ->useAttributeAsKey('name') + ->prototype('scalar')->end() + ->end() + ->arrayNode('includes') + ->useAttributeAsKey('name') + ->prototype('scalar')->end() + ->end() + ->end() + ; + + return $node; + } } diff --git a/DependencyInjection/FOQElasticaExtension.php b/DependencyInjection/FOQElasticaExtension.php index 413344e..a0ae7e9 100644 --- a/DependencyInjection/FOQElasticaExtension.php +++ b/DependencyInjection/FOQElasticaExtension.php @@ -167,8 +167,11 @@ class FOQElasticaExtension extends Extension $typeDef->setFactoryService($indexId); $typeDef->setFactoryMethod('getType'); $container->setDefinition($typeId, $typeDef); + if (isset($type['_source'])) { + $this->indexConfigs[$indexName]['config']['mappings'][$name]['_source'] = $type['_source']; + } if (isset($type['mappings'])) { - $this->indexConfigs[$indexName]['config']['mappings'][$name] = array('properties' => $type['mappings']); + $this->indexConfigs[$indexName]['config']['mappings'][$name]['properties'] = $type['mappings']; $typeName = sprintf('%s/%s', $indexName, $name); $this->typeFields[$typeName] = array_keys($type['mappings']); }