diff --git a/CHANGELOG-2.1.md b/CHANGELOG-2.1.md new file mode 100644 index 0000000..f4373e7 --- /dev/null +++ b/CHANGELOG-2.1.md @@ -0,0 +1,18 @@ +CHANGELOG for 2.1.x +=================== + +This changelog references the relevant changes (bug and security fixes) done +in 2.1 minor versions. + +To get the diff for a specific change, go to +https://github.com/FriendsOfSymfony/FOSElasticaBundle/commit/XXX where XXX is +the commit hash. To get the diff between two versions, go to +https://github.com/FriendsOfSymfony/FOSElasticaBundle/compare/v2.1.0...v2.1.1 + +To generate a changelog summary since the last version, run +`git log --no-merges --oneline v2.1.0...2.1.x` + +* 2.1.0 (2013-5-15) + + * c05e0ca: Added documentation for ignoring missing hits + * 00b67fd: Ignore missing index hits diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 966f04f..f79eece 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -177,6 +177,7 @@ class Configuration implements ConfigurationInterface ->addDefaultsIfNotSet() ->children() ->scalarNode('hydrate')->defaultTrue()->end() + ->scalarNode('ignore_missing')->defaultFalse()->end() ->scalarNode('service')->end() ->end() ->end() @@ -267,6 +268,7 @@ class Configuration implements ConfigurationInterface ->addDefaultsIfNotSet() ->children() ->scalarNode('hydrate')->defaultTrue()->end() + ->scalarNode('ignore_missing')->defaultFalse()->end() ->scalarNode('service')->end() ->end() ->end() diff --git a/DependencyInjection/FOSElasticaExtension.php b/DependencyInjection/FOSElasticaExtension.php index 3f757df..473cec3 100644 --- a/DependencyInjection/FOSElasticaExtension.php +++ b/DependencyInjection/FOSElasticaExtension.php @@ -290,8 +290,9 @@ class FOSElasticaExtension extends Extension $serviceDef->replaceArgument($argPos, $typeConfig['model']); $serviceDef->replaceArgument($argPos + 1, array( - 'identifier' => $typeConfig['identifier'], - 'hydrate' => $typeConfig['elastica_to_model_transformer']['hydrate'] + 'hydrate' => $typeConfig['elastica_to_model_transformer']['hydrate'], + 'identifier' => $typeConfig['identifier'], + 'ignore_missing' => $typeConfig['elastica_to_model_transformer']['ignore_missing'] )); $container->setDefinition($serviceId, $serviceDef); diff --git a/Doctrine/AbstractElasticaToModelTransformer.php b/Doctrine/AbstractElasticaToModelTransformer.php index f796eec..e8f9472 100755 --- a/Doctrine/AbstractElasticaToModelTransformer.php +++ b/Doctrine/AbstractElasticaToModelTransformer.php @@ -32,8 +32,9 @@ abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTran * @var array */ protected $options = array( - 'hydrate' => true, - 'identifier' => 'id' + 'hydrate' => true, + 'identifier' => 'id', + 'ignore_missing' => false, ); /** @@ -94,7 +95,7 @@ abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTran } $objects = $this->findByIdentifiers($ids, $this->options['hydrate']); - if (count($objects) < count($elasticaObjects)) { + if (!$this->options['ignore_missing'] && count($objects) < count($elasticaObjects)) { throw new \RuntimeException('Cannot find corresponding Doctrine objects for all Elastica results.'); }; diff --git a/README.md b/README.md index 822cf3f..555f5b1 100644 --- a/README.md +++ b/README.md @@ -602,6 +602,23 @@ The delete listener disregards the callback_class. > **Propel** doesn't support this feature yet. +### Ignoring missing index results + +By default, FOSElasticaBundle will throw an exception if the results returned from +Elasticsearch are different from the results it finds from the chosen persistence +provider. This may pose problems for a large index where updates do not occur instantly +or another process has removed the results from your persistence provider without +updating Elasticsearch. + +The error you're likely to see is something like: +'Cannot find corresponding Doctrine objects for all Elastica results.' + +To solve this issue, each mapped object can be configured to ignore the missing results: + + persistence: + elastica_to_model_transformer: + ignore_missing: true + ### Advanced elasticsearch configuration Any setting can be specified when declaring a type. For example, to enable a custom analyzer, you could write: