Merge pull request #85 from nurikabe/2.0

Allow "_source" configuration.
This commit is contained in:
Jeremy Mikola 2012-04-17 09:20:42 -07:00
commit 96776e34ad
2 changed files with 29 additions and 1 deletions

View file

@ -207,6 +207,7 @@ class Configuration
->end()
->end()
->append($this->getMappingsNode())
->append($this->getSourceNode())
->end()
;
@ -256,4 +257,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;
}
}

View file

@ -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']);
}