From fad481d8222be4e6b49f3bcdaf120be76958d008 Mon Sep 17 00:00:00 2001 From: Tim Nagel Date: Wed, 23 Jul 2014 20:00:14 +1000 Subject: [PATCH 1/4] Fix completion type --- Index/MappingBuilder.php | 16 +++++++++++++--- Tests/Functional/app/Basic/config.yml | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Index/MappingBuilder.php b/Index/MappingBuilder.php index f3474be..fc67420 100644 --- a/Index/MappingBuilder.php +++ b/Index/MappingBuilder.php @@ -16,6 +16,13 @@ use FOS\ElasticaBundle\Configuration\TypeConfig; class MappingBuilder { + /** + * Skip adding default information to certain fields. + * + * @var array + */ + private $skipTypes = array('completion'); + /** * Builds mappings for an entire index. * @@ -85,12 +92,15 @@ class MappingBuilder if (!isset($property['type'])) { $property['type'] = 'string'; } - if (!isset($property['store'])) { - $property['store'] = true; - } if (isset($property['properties'])) { $this->fixProperties($property['properties']); } + if (in_array($property['type'], $this->skipTypes)) { + continue; + } + if (!isset($property['store'])) { + $property['store'] = true; + } } } } diff --git a/Tests/Functional/app/Basic/config.yml b/Tests/Functional/app/Basic/config.yml index 3552b3d..607e3cc 100644 --- a/Tests/Functional/app/Basic/config.yml +++ b/Tests/Functional/app/Basic/config.yml @@ -60,6 +60,8 @@ fos_elastica: type: integer store: false date: { boost: 5 } + completion: + type: completion title: { boost: 8, analyzer: my_analyzer } content: ~ comments: From e5410a5b650cddd3e1b9f128c7701496b3bda5b9 Mon Sep 17 00:00:00 2001 From: Tim Nagel Date: Wed, 23 Jul 2014 21:38:46 +1000 Subject: [PATCH 2/4] Fix indexable callbacks being overwritten by another index closes #663 --- DependencyInjection/FOSElasticaExtension.php | 15 ++++++++------- Tests/Functional/app/ORM/config.yml | 12 ++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/DependencyInjection/FOSElasticaExtension.php b/DependencyInjection/FOSElasticaExtension.php index 292a9a5..e523bf4 100644 --- a/DependencyInjection/FOSElasticaExtension.php +++ b/DependencyInjection/FOSElasticaExtension.php @@ -128,6 +128,8 @@ class FOSElasticaExtension extends Extension */ private function loadIndexes(array $indexes, ContainerBuilder $container) { + $indexableCallbacks = array(); + foreach ($indexes as $name => $index) { $indexId = sprintf('fos_elastica.index.%s', $name); $indexName = isset($index['index_name']) ? $index['index_name']: $name; @@ -159,8 +161,11 @@ class FOSElasticaExtension extends Extension $this->loadIndexFinder($container, $name, $reference); } - $this->loadTypes((array) $index['types'], $container, $this->indexConfigs[$name]); + $this->loadTypes((array) $index['types'], $container, $this->indexConfigs[$name], $indexableCallbacks); } + + $indexable = $container->getDefinition('fos_elastica.indexable'); + $indexable->replaceArgument(0, $indexableCallbacks); } /** @@ -194,11 +199,10 @@ class FOSElasticaExtension extends Extension * @param array $types * @param ContainerBuilder $container * @param array $indexConfig + * @param array $indexableCallbacks */ - private function loadTypes(array $types, ContainerBuilder $container, array $indexConfig) + private function loadTypes(array $types, ContainerBuilder $container, array $indexConfig, array &$indexableCallbacks) { - $indexableCallbacks = array(); - foreach ($types as $name => $type) { $indexName = $indexConfig['name']; @@ -269,9 +273,6 @@ class FOSElasticaExtension extends Extension $container->setDefinition($typeSerializerId, $typeSerializerDef); } } - - $indexable = $container->getDefinition('fos_elastica.indexable'); - $indexable->replaceArgument(0, $indexableCallbacks); } /** diff --git a/Tests/Functional/app/ORM/config.yml b/Tests/Functional/app/ORM/config.yml index 3dc0e63..02d7a92 100644 --- a/Tests/Functional/app/ORM/config.yml +++ b/Tests/Functional/app/ORM/config.yml @@ -63,3 +63,15 @@ fos_elastica: provider: ~ listener: is_indexable_callback: [ 'FOS\ElasticaBundle\Tests\Functional\app\ORM\IndexableService', 'isntIndexable' ] + second_index: + index_name: foselastica_orm_test_second_%kernel.environment% + types: + type: + properties: + field1: ~ + coll: ~ + persistence: + driver: orm + model: FOS\ElasticaBundle\Tests\Functional\TypeObj + listener: + is_indexable_callback: 'object.isIndexable() && !object.isntIndexable()' From 11ee25cfea23a1d2743bc875eb1ecacdaf3f5d8c Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Wed, 9 Jul 2014 12:29:01 +0200 Subject: [PATCH 3/4] Added PHP 5.6 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a884d86..034cd84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: - 5.3 - 5.4 - 5.5 + - 5.6 before_script: - sudo /usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/2.0.0 From 9befa90f4192701779181862fee5f7965af2b95d Mon Sep 17 00:00:00 2001 From: Pablo Date: Fri, 25 Jul 2014 17:59:24 +0200 Subject: [PATCH 4/4] Return repository in Manager Class MongoDB --- Doctrine/MongoDB/ElasticaToModelTransformer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Doctrine/MongoDB/ElasticaToModelTransformer.php b/Doctrine/MongoDB/ElasticaToModelTransformer.php index 855a093..cea737f 100644 --- a/Doctrine/MongoDB/ElasticaToModelTransformer.php +++ b/Doctrine/MongoDB/ElasticaToModelTransformer.php @@ -22,6 +22,7 @@ class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer { return $this->registry ->getManagerForClass($this->objectClass) + ->getRepository($this->objectClass) ->{$this->options['query_builder_method']}($this->objectClass) ->field($this->options['identifier'])->in($identifierValues) ->hydrate($hydrate)