Allow "_source" configuration as per https://github.com/Exercise/FOQElasticaBundle/issues/83.
This commit is contained in:
parent
45747a3e1f
commit
99c6aa9ac7
|
@ -207,6 +207,7 @@ class Configuration
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->append($this->getMappingsNode())
|
->append($this->getMappingsNode())
|
||||||
|
->append($this->getSourceNode())
|
||||||
->end()
|
->end()
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -256,4 +257,30 @@ class Configuration
|
||||||
|
|
||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the array node used for "_source".
|
||||||
|
*/
|
||||||
|
protected function getSourceNode()
|
||||||
|
{
|
||||||
|
$builder = new TreeBuilder();
|
||||||
|
$node = $builder->root('_source');
|
||||||
|
|
||||||
|
$node
|
||||||
|
->children()
|
||||||
|
->arrayNode('excludes')
|
||||||
|
->addDefaultsIfNotSet()
|
||||||
|
->useAttributeAsKey('name')
|
||||||
|
->prototype('scalar')->end()
|
||||||
|
->end()
|
||||||
|
->arrayNode('includes')
|
||||||
|
->addDefaultsIfNotSet()
|
||||||
|
->useAttributeAsKey('name')
|
||||||
|
->prototype('scalar')->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
;
|
||||||
|
|
||||||
|
return $node;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,8 +167,11 @@ class FOQElasticaExtension extends Extension
|
||||||
$typeDef->setFactoryService($indexId);
|
$typeDef->setFactoryService($indexId);
|
||||||
$typeDef->setFactoryMethod('getType');
|
$typeDef->setFactoryMethod('getType');
|
||||||
$container->setDefinition($typeId, $typeDef);
|
$container->setDefinition($typeId, $typeDef);
|
||||||
|
if (isset($type['_source'])) {
|
||||||
|
$this->indexConfigs[$indexName]['config']['mappings'][$name]['_source'] = $type['_source'];
|
||||||
|
}
|
||||||
if (isset($type['mappings'])) {
|
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);
|
$typeName = sprintf('%s/%s', $indexName, $name);
|
||||||
$this->typeFields[$typeName] = array_keys($type['mappings']);
|
$this->typeFields[$typeName] = array_keys($type['mappings']);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue