1 | <?php |
||
26 | class SearchCommand extends Command |
||
27 | { |
||
28 | protected static $defaultName = 'fos:elastica:search'; |
||
29 | |||
30 | private $indexManager; |
||
31 | |||
32 | 4 | public function __construct(IndexManager $indexManager) |
|
33 | { |
||
34 | 4 | parent::__construct(); |
|
35 | |||
36 | 4 | $this->indexManager = $indexManager; |
|
37 | 4 | } |
|
38 | |||
39 | 4 | protected function configure() |
|
40 | { |
||
41 | $this |
||
42 | 4 | ->setName('fos:elastica:search') |
|
43 | 4 | ->addArgument('type', InputArgument::REQUIRED, 'The type to search in') |
|
44 | 4 | ->addArgument('query', InputArgument::REQUIRED, 'The text to search') |
|
45 | 4 | ->addOption('index', null, InputOption::VALUE_REQUIRED, 'The index to search in') |
|
46 | 4 | ->addOption('limit', null, InputOption::VALUE_REQUIRED, 'The maximum number of documents to return', 20) |
|
47 | 4 | ->addOption('show-field', null, InputOption::VALUE_REQUIRED, 'Field to show, null uses the first field') |
|
48 | 4 | ->addOption('show-source', null, InputOption::VALUE_NONE, 'Show the documents sources') |
|
49 | 4 | ->addOption('show-id', null, InputOption::VALUE_NONE, 'Show the documents ids') |
|
50 | 4 | ->addOption('explain', null, InputOption::VALUE_NONE, 'Enables explanation for each hit on how its score was computed.') |
|
51 | 4 | ->setDescription('Searches documents in a given type and index') |
|
52 | ; |
||
53 | 4 | } |
|
54 | |||
55 | protected function execute(InputInterface $input, OutputInterface $output) |
||
73 | |||
74 | /** |
||
75 | * @param Result $result |
||
76 | * @param string $showField |
||
77 | * @param string $showSource |
||
78 | * @param string $showId |
||
79 | * @param string $explain |
||
80 | * |
||
81 | * @return string |
||
82 | */ |
||
83 | protected function formatResult(Result $result, $showField, $showSource, $showId, $explain) |
||
104 | } |
||
105 |