Command to update index mapping

This commit is contained in:
Mathieu Darse
2015-03-23 18:56:22 +01:00
parent 5d651fc782
commit f2f29c4290
3 changed files with 72 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ use Alchemy\Phrasea\Command\Setup\H264MappingGenerator;
use Alchemy\Phrasea\Command\SearchEngine\Debug\QueryParseCommand; 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\MappingUpdateCommand;
use Alchemy\Phrasea\Command\SearchEngine\IndexPopulateCommand; use Alchemy\Phrasea\Command\SearchEngine\IndexPopulateCommand;
use Alchemy\Phrasea\Command\Thesaurus\FindConceptsCommand; use Alchemy\Phrasea\Command\Thesaurus\FindConceptsCommand;
use Alchemy\Phrasea\Command\WebsocketServer; use Alchemy\Phrasea\Command\WebsocketServer;
@@ -125,6 +125,7 @@ $cli->command(new XSendFileMappingGenerator());
if ($cli['search_engine.type'] === SearchEngineInterface::TYPE_ELASTICSEARCH) { 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 MappingUpdateCommand());
$cli->command(new IndexPopulateCommand()); $cli->command(new IndexPopulateCommand());
$cli->command(new QueryParseCommand()); $cli->command(new QueryParseCommand());
$cli->command(new FindConceptsCommand()); $cli->command(new FindConceptsCommand());

View File

@@ -0,0 +1,69 @@
<?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 Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class QuerySampleCommand extends Command
{
protected function configure()
{
$this
->setName('searchengine:query:sample')
->setDescription('Generate sample queries from grammar')
;
}
protected function doExecute(InputInterface $input, OutputInterface $output)
{
$grammarPath = $this->container['query_parser.grammar_path'];
$output->writeln(sprintf('Generating sample queries from <comment>%s</comment>', $grammarPath));
$output->writeln(str_repeat('-', 20));
$parser = $this->container['query_parser'];
// UNIFORM
// $sampler = new \Hoa\Compiler\Llk\Sampler\Uniform(
// $parser,
// new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random()),
// 7
// );
// for($i = 0; $i < 10; ++$i) {
// $output->writeln(sprintf('%d => %s', $i, $sampler->uniform()));
// }
// BOUNDED EXAUSTIVE
$sampler = new \Hoa\Compiler\Llk\Sampler\BoundedExhaustive(
$parser,
new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random()),
6
);
// COVERAGE
// $sampler = new \Hoa\Compiler\Llk\Sampler\Coverage(
// $parser,
// new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random())
// );
foreach($sampler as $i => $data) {
$output->writeln(sprintf('%d => %s', $i, $data));
}
$output->writeln(str_repeat('-', 20));
}
}

View File

@@ -83,8 +83,7 @@ class Indexer
$params['index'] = $this->options['index']; $params['index'] = $this->options['index'];
$params['type'] = RecordIndexer::TYPE_NAME; $params['type'] = RecordIndexer::TYPE_NAME;
$params['body'][RecordIndexer::TYPE_NAME] = $this->recordIndexer->getMapping(); $params['body'][RecordIndexer::TYPE_NAME] = $this->recordIndexer->getMapping();
$params['body'][TermIndexer::TYPE_NAME] = $this->termIndexer->getMapping();
// @todo Add term mapping
// @todo This must throw a new indexation if a mapping is edited // @todo This must throw a new indexation if a mapping is edited
$this->client->indices()->putMapping($params); $this->client->indices()->putMapping($params);