Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
saimaz committed Feb 20, 2020
2 parents e1a6398 + 7678794 commit fe3801c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Command/AbstractIndexServiceAwareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@

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
{
private $container;

const INDEX_OPTION = 'index';

public function __construct(Container $container)
public function __construct(ContainerInterface $container)
{
$this->container = $container;
parent::__construct();
Expand Down Expand Up @@ -58,7 +58,7 @@ protected function getIndex($name): IndexService
);
}

public function getContainer(): Container
public function getContainer(): ContainerInterface
{
return $this->container;
}
Expand Down
25 changes: 17 additions & 8 deletions DependencyInjection/Compiler/MappingPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Product
public $id;

/**
* @ES\Property(type="text", "analyzer"="eNgramAnalyzer")
* @ES\Property(type="text", analyzer="eNgramAnalyzer")
*/
public $title;

Expand Down
6 changes: 4 additions & 2 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ parameters:

services:

_defaults: { public: true }
_defaults:
public: true
autowire: true

ONGR\ElasticsearchBundle\Command\:
resource: '../../Command'
Expand Down Expand Up @@ -45,4 +47,4 @@ services:
ONGR\ElasticsearchBundle\EventListener\TerminateListener:
arguments: ["@service_container", "%ongr.esb.indexes%"]
tags:
- { name: kernel.event_listener, event: kernel.terminate }
- { name: kernel.event_listener, event: kernel.terminate }
2 changes: 1 addition & 1 deletion Result/DocumentIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit fe3801c

Please sign in to comment.