diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index fbcd486..e672d80 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -132,7 +132,6 @@ class Configuration implements ConfigurationInterface ->arrayNode('indexes') ->useAttributeAsKey('name') ->prototype('array') - ->performNoDeepMerging() ->children() ->scalarNode('index_name')->end() ->scalarNode('client')->end() @@ -301,6 +300,8 @@ class Configuration implements ConfigurationInterface ->append($this->getRoutingNode()) ->append($this->getParentNode()) ->append($this->getAllNode()) + ->append($this->getTimestampNode()) + ->append($this->getTtlNode()) ->end() ; @@ -401,7 +402,8 @@ class Configuration implements ConfigurationInterface ->scalarNode('identifier')->defaultValue('id')->end() ->end() ->end() - ->scalarNode('format')->end(); + ->scalarNode('format')->end() + ->scalarNode('similarity')->end(); ; if (isset($nestings['fields'])) { @@ -649,4 +651,45 @@ class Configuration implements ConfigurationInterface return $node; } + + /** + * Returns the array node used for "_timestamp" + */ + protected function getTimestampNode() + { + $builder = new TreeBuilder(); + $node = $builder->root('_timestamp'); + + $node + ->children() + ->scalarNode('enabled')->defaultValue(true)->end() + ->scalarNode('path')->end() + ->scalarNode('format')->end() + ->scalarNode('store')->end() + ->scalarNode('index')->end() + ->end() + ; + + return $node; + } + + /** + * Returns the array node used for "_ttl" + */ + protected function getTtlNode() + { + $builder = new TreeBuilder(); + $node = $builder->root('_ttl'); + + $node + ->children() + ->scalarNode('enabled')->defaultValue(true)->end() + ->scalarNode('default')->end() + ->scalarNode('store')->end() + ->scalarNode('index')->end() + ->end() + ; + + return $node; + } } diff --git a/DependencyInjection/FOSElasticaExtension.php b/DependencyInjection/FOSElasticaExtension.php index 53c91f1..92801ed 100644 --- a/DependencyInjection/FOSElasticaExtension.php +++ b/DependencyInjection/FOSElasticaExtension.php @@ -246,6 +246,12 @@ class FOSElasticaExtension extends Extension if (isset($type['_all'])) { $this->indexConfigs[$indexName]['config']['mappings'][$name]['_all'] = $type['_all']; } + if (isset($type['_timestamp'])) { + $this->indexConfigs[$indexName]['config']['mappings'][$name]['_timestamp'] = $type['_timestamp']; + } + if (isset($type['_ttl'])) { + $this->indexConfigs[$indexName]['config']['mappings'][$name]['_ttl'] = $type['_ttl']; + } if (!empty($type['dynamic_templates'])) { $this->indexConfigs[$indexName]['config']['mappings'][$name]['dynamic_templates'] = array(); foreach ($type['dynamic_templates'] as $templateName => $templateData) { diff --git a/README.md b/README.md index cb6e5f8..ade48ea 100644 --- a/README.md +++ b/README.md @@ -526,7 +526,7 @@ class UserRepository extends Repository public function findWithCustomQuery($searchText) { // build $query with Elastica objects - $this->find($query); + return $this->find($query); } } ``` diff --git a/Resources/config/config.xml b/Resources/config/config.xml index 1fb2c1d..85cfbed 100644 --- a/Resources/config/config.xml +++ b/Resources/config/config.xml @@ -14,6 +14,10 @@ FOS\ElasticaBundle\Transformer\ElasticaToModelTransformerCollection FOS\ElasticaBundle\Provider\ProviderRegistry Symfony\Component\PropertyAccess\PropertyAccessor + FOS\ElasticaBundle\Persister\ObjectPersister + FOS\ElasticaBundle\Persister\ObjectSerializerPersister + FOS\ElasticaBundle\Transformer\ModelToElasticaAutoTransformer + FOS\ElasticaBundle\Transformer\ModelToElasticaIdentifierTransformer @@ -37,7 +41,7 @@ - + @@ -49,21 +53,21 @@ - + - + - +