From 50730cca3d59f3429bfc0908424c4e998ab780df Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Fri, 17 May 2013 00:22:46 +0200 Subject: [PATCH] added path support, see http://www.elasticsearch.org/guide/reference/mapping/id-field/ --- DependencyInjection/Configuration.php | 18 ++++++++++++++++++ DependencyInjection/FOSElasticaExtension.php | 3 +++ 2 files changed, 21 insertions(+) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f79eece..d901bfb 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -281,6 +281,7 @@ class Configuration implements ConfigurationInterface ->end() ->end() ->end() + ->append($this->getIdNode()) ->append($this->getMappingsNode()) ->append($this->getSourceNode()) ->append($this->getBoostNode()) @@ -435,6 +436,23 @@ class Configuration implements ConfigurationInterface $nestings[$property] = array_merge_recursive($nestings[$property], $this->getNestingsForType($field[$property])); } + /** + * Returns the array node used for "_id". + */ + protected function getIdNode() + { + $builder = new TreeBuilder(); + $node = $builder->root('_id'); + + $node + ->children() + ->scalarNode('path')->end() + ->end() + ; + + return $node; + } + /** * Returns the array node used for "_source". */ diff --git a/DependencyInjection/FOSElasticaExtension.php b/DependencyInjection/FOSElasticaExtension.php index 473cec3..c28fb99 100644 --- a/DependencyInjection/FOSElasticaExtension.php +++ b/DependencyInjection/FOSElasticaExtension.php @@ -197,6 +197,9 @@ class FOSElasticaExtension extends Extension $typeDef->addMethodCall('setSerializer', array(array(new Reference($callbackId), 'serialize'))); } $container->setDefinition($typeId, $typeDef); + if (isset($type['_id'])) { + $this->indexConfigs[$indexName]['config']['mappings'][$name]['_id'] = $type['_id']; + } if (isset($type['_source'])) { $this->indexConfigs[$indexName]['config']['mappings'][$name]['_source'] = $type['_source']; }