diff --git a/Command/AbstractIndexServiceAwareCommand.php b/Command/AbstractIndexServiceAwareCommand.php index c9825dd4..27b33111 100644 --- a/Command/AbstractIndexServiceAwareCommand.php +++ b/Command/AbstractIndexServiceAwareCommand.php @@ -13,10 +13,10 @@ use ONGR\ElasticsearchBundle\DependencyInjection\Configuration; use ONGR\ElasticsearchBundle\Service\IndexService; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\DependencyInjection\ContainerInterface; abstract class AbstractIndexServiceAwareCommand extends Command { @@ -24,7 +24,7 @@ abstract class AbstractIndexServiceAwareCommand extends Command const INDEX_OPTION = 'index'; - public function __construct(Container $container) + public function __construct(ContainerInterface $container) { $this->container = $container; parent::__construct(); @@ -58,7 +58,7 @@ protected function getIndex($name): IndexService ); } - public function getContainer(): Container + public function getContainer(): ContainerInterface { return $this->container; } diff --git a/DependencyInjection/Compiler/MappingPass.php b/DependencyInjection/Compiler/MappingPass.php index e0b8ee0f..4bdd3be9 100644 --- a/DependencyInjection/Compiler/MappingPass.php +++ b/DependencyInjection/Compiler/MappingPass.php @@ -75,14 +75,23 @@ private function handleDirectoryMapping(ContainerBuilder $container, string $dir $indexMetadata = $parser->getIndexMetadata($class); if (!empty($indexMetadata)) { - $indexMetadata['settings'] = array_filter(array_merge_recursive( - $indexMetadata['settings'] ?? [], - [ - 'number_of_replicas' => $document->numberOfReplicas, - 'number_of_shards' => $document->numberOfShards, - ], - $indexesOverride[$namespace]['settings'] ?? [] - )); + $indexMetadata['settings'] = array_filter( + array_replace_recursive( + $indexMetadata['settings'] ?? [], + [ + 'number_of_replicas' => $document->numberOfReplicas, + 'number_of_shards' => $document->numberOfShards, + ], + $indexesOverride[$namespace]['settings'] ?? [] + ), + function ($value) { + if (0 === $value) { + return true; + } + + return (bool)$value; + } + ); $indexSettings = new Definition( IndexSettings::class, diff --git a/README.md b/README.md index 1a65ee6e..60ae18e5 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ class Product public $id; /** - * @ES\Property(type="text", "analyzer"="eNgramAnalyzer") + * @ES\Property(type="text", analyzer="eNgramAnalyzer") */ public $title; diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 6b9ac085..7d4bbb3f 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -3,7 +3,9 @@ parameters: services: - _defaults: { public: true } + _defaults: + public: true + autowire: true ONGR\ElasticsearchBundle\Command\: resource: '../../Command' @@ -45,4 +47,4 @@ services: ONGR\ElasticsearchBundle\EventListener\TerminateListener: arguments: ["@service_container", "%ongr.esb.indexes%"] tags: - - { name: kernel.event_listener, event: kernel.terminate } \ No newline at end of file + - { name: kernel.event_listener, event: kernel.terminate } diff --git a/Result/DocumentIterator.php b/Result/DocumentIterator.php index 7665fe9f..bc767930 100644 --- a/Result/DocumentIterator.php +++ b/Result/DocumentIterator.php @@ -41,6 +41,6 @@ protected function convertDocument(array $raw) $data = $raw['_source'] ?? $raw['_fields'] ?? null; $data['_id'] = $raw['_id'] ?? null; - return $this->getConverter()->convertArrayToDocument($this->getIndex()->getNamespace(), array_filter($data)); + return $this->getConverter()->convertArrayToDocument($this->getIndex()->getNamespace(), $data); } }