From 00b67fd8a4e10c132bb3ed7a82d40169bd420ab4 Mon Sep 17 00:00:00 2001 From: Tim Nagel Date: Thu, 18 Apr 2013 10:01:34 +1000 Subject: [PATCH 1/3] Ignore missing index hits --- DependencyInjection/Configuration.php | 2 ++ DependencyInjection/FOSElasticaExtension.php | 5 +++-- Doctrine/AbstractElasticaToModelTransformer.php | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 4482a4c..df0fe19 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -170,6 +170,7 @@ class Configuration implements ConfigurationInterface ->addDefaultsIfNotSet() ->children() ->scalarNode('hydrate')->defaultTrue()->end() + ->scalarNode('ignore_missing')->defaultFalse()->end() ->scalarNode('service')->end() ->end() ->end() @@ -250,6 +251,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 0cb5c27..6d38714 100644 --- a/DependencyInjection/FOSElasticaExtension.php +++ b/DependencyInjection/FOSElasticaExtension.php @@ -272,8 +272,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.'); }; From c05e0caa9cdc5c599780dd740be843c92bfdbbce Mon Sep 17 00:00:00 2001 From: Tim Nagel Date: Thu, 2 May 2013 10:18:05 +1000 Subject: [PATCH 2/3] Added documentation for ignoring missing hits --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 0bcae02..c289cd6 100644 --- a/README.md +++ b/README.md @@ -534,6 +534,23 @@ The delete listener disregards the callback. > **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: From 41c747907c483043c47d6160daf7a048030d7a9d Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Wed, 15 May 2013 10:55:30 -0500 Subject: [PATCH 3/3] Create 2.1.x changelog --- CHANGELOG-2.1.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 CHANGELOG-2.1.md 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