mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 10:23:17 +00:00
New query debug command
This commit is contained in:
2
bin/console
Normal file → Executable file
2
bin/console
Normal file → Executable file
@@ -14,6 +14,7 @@ namespace KonsoleKommander;
|
|||||||
use Alchemy\Phrasea\Command\Plugin\ListPlugin;
|
use Alchemy\Phrasea\Command\Plugin\ListPlugin;
|
||||||
use Alchemy\Phrasea\Command\Setup\H264ConfigurationDumper;
|
use Alchemy\Phrasea\Command\Setup\H264ConfigurationDumper;
|
||||||
use Alchemy\Phrasea\Command\Setup\H264MappingGenerator;
|
use Alchemy\Phrasea\Command\Setup\H264MappingGenerator;
|
||||||
|
use Alchemy\Phrasea\Command\SearchEngine\Debug\QueryParseCommand;
|
||||||
use Alchemy\Phrasea\Command\SearchEngine\IndexCreateCommand;
|
use Alchemy\Phrasea\Command\SearchEngine\IndexCreateCommand;
|
||||||
use Alchemy\Phrasea\Command\SearchEngine\IndexDropCommand;
|
use Alchemy\Phrasea\Command\SearchEngine\IndexDropCommand;
|
||||||
use Alchemy\Phrasea\Command\SearchEngine\IndexFull;
|
use Alchemy\Phrasea\Command\SearchEngine\IndexFull;
|
||||||
@@ -127,6 +128,7 @@ if ($cli['search_engine.type'] === SearchEngineInterface::TYPE_ELASTICSEARCH) {
|
|||||||
$cli->command(new IndexCreateCommand());
|
$cli->command(new IndexCreateCommand());
|
||||||
$cli->command(new IndexDropCommand());
|
$cli->command(new IndexDropCommand());
|
||||||
$cli->command(new IndexPopulateCommand());
|
$cli->command(new IndexPopulateCommand());
|
||||||
|
$cli->command(new QueryParseCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
$cli->command(new WebsocketServer('ws-server:run'));
|
$cli->command(new WebsocketServer('ws-server:run'));
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2014 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Command\SearchEngine\Debug;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class QueryParseCommand extends Command
|
||||||
|
{
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->setName('searchengine:query:parse')
|
||||||
|
->setDescription('Debug a search query')
|
||||||
|
->addArgument(
|
||||||
|
'query',
|
||||||
|
InputArgument::REQUIRED,
|
||||||
|
'The query to debug'
|
||||||
|
)
|
||||||
|
->addOption(
|
||||||
|
'raw',
|
||||||
|
false,
|
||||||
|
InputOption::VALUE_NONE,
|
||||||
|
'Only output query dump'
|
||||||
|
)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$string = $input->getArgument('query');
|
||||||
|
$raw = $input->getOption('raw');
|
||||||
|
|
||||||
|
if (!$raw) {
|
||||||
|
$output->writeln(sprintf('Parsing search query: <comment>%s</comment>', $string));
|
||||||
|
$output->writeln(str_repeat('-', 20));
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $this->container['query_parser']->parse($string);
|
||||||
|
$dump = $query->dump();
|
||||||
|
|
||||||
|
if (!$raw) {
|
||||||
|
$output->writeln($dump);
|
||||||
|
} else {
|
||||||
|
$output->write($dump);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,4 +24,9 @@ class SearchQuery
|
|||||||
{
|
{
|
||||||
return (string) $this->root;
|
return (string) $this->root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function dump()
|
||||||
|
{
|
||||||
|
return (string) $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user