Skip to content

Commit

Permalink
Merge pull request #85 from nurikabe/2.0
Browse files Browse the repository at this point in the history
Allow "_source" configuration.
  • Loading branch information
jmikola committed Apr 17, 2012
2 parents c3391d9 + 87f1141 commit 96776e3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
25 changes: 25 additions & 0 deletions DependencyInjection/Configuration.php
Expand Up @@ -207,6 +207,7 @@ protected function getTypesNode()
->end()
->end()
->append($this->getMappingsNode())
->append($this->getSourceNode())
->end()
;

Expand Down Expand Up @@ -256,4 +257,28 @@ protected function getMappingsNode()

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;
}
}
5 changes: 4 additions & 1 deletion DependencyInjection/FOQElasticaExtension.php
Expand Up @@ -167,8 +167,11 @@ protected function loadTypes(array $types, ContainerBuilder $container, $indexNa
$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']);
}
Expand Down

0 comments on commit 96776e3

Please sign in to comment.