From 3cdfcf1cea01048c6403884bdbfdeb74f5895602 Mon Sep 17 00:00:00 2001 From: Gunther Konig Date: Fri, 10 Aug 2012 11:40:01 +0300 Subject: [PATCH] fix search command when no index option is passed --- Command/SearchCommand.php | 3 ++- IndexManager.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Command/SearchCommand.php b/Command/SearchCommand.php index debd46b..5f189fd 100644 --- a/Command/SearchCommand.php +++ b/Command/SearchCommand.php @@ -40,7 +40,8 @@ class SearchCommand extends ContainerAwareCommand */ protected function execute(InputInterface $input, OutputInterface $output) { - $index = $this->getContainer()->get('foq_elastica.index_manager')->getIndex($input->getOption('index')); + $indexName = $input->getOption('index'); + $index = $this->getContainer()->get('foq_elastica.index_manager')->getIndex($indexName ? $indexName : null); $type = $index->getType($input->getArgument('type')); $query = Elastica_Query::create($input->getArgument('query')); $query->setLimit($input->getOption('limit')); diff --git a/IndexManager.php b/IndexManager.php index 3891088..b117847 100644 --- a/IndexManager.php +++ b/IndexManager.php @@ -13,10 +13,10 @@ class IndexManager * @param array $indexesByName * @param string $defaultIndexName */ - public function __construct(array $indexesByName, $defaultIndexName) + public function __construct(array $indexesByName, $defaultIndex) { $this->indexesByName = $indexesByName; - $this->defaultIndexName = $defaultIndexName; + $this->defaultIndexName = $defaultIndex->getName(); } /**