Merge pull request #85 from nurikabe/2.0
Allow "_source" configuration.
This commit is contained in:
commit
96776e34ad
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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']);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue