Merge branch '2.1.x'

This commit is contained in:
Jeremy Mikola 2013-05-15 10:58:47 -05:00
commit 814460dbf2
5 changed files with 44 additions and 5 deletions

18
CHANGELOG-2.1.md Normal file
View file

@ -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

View file

@ -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()

View file

@ -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);

View file

@ -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.');
};

View file

@ -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: