/**
  * Rebuilds an index.
  *
  * @param array $arguments
  * @param array $options
  */
 public function execute($arguments = array(), $options = array())
 {
     $index = $arguments['index'];
     $this->checkIndexExists($index);
     $prefix = $this->formatter->format($arguments['index'], array('fg' => 'green', 'bold' => true)) . ' >> ';
     $index = new $index();
     $index->setLogger(new xfLoggerTask($this->dispatcher, $this->formatter));
     $parser = new xfParserLucene();
     $criteria = $parser->parse($arguments['query']);
     $this->log($prefix . 'Query ' . $this->formatter->format($criteria->toString(), array('fg' => 'blue', 'bold' => true)));
     $results = $index->find($criteria);
     $pager = new xfPager($results);
     $pager->setPerPage($options['limit']);
     $pager->setPage($options['page']);
     if ($pager->getNbResults() == 0) {
         $this->log($prefix . $this->formatter->format('No', array('fg' => 'red', 'bold' => true)) . ' results found.');
         return;
     } elseif ($pager->getNbResults() == 1) {
         $this->log($prefix . $this->formatter->format('1', array('fg' => 'blue', 'bold' => true)) . ' result found:');
     } else {
         $this->log($prefix . $this->formatter->format($pager->getNbResults(), array('fg' => 'blue', 'bold' => true)) . ' results found:');
     }
     if ($pager->getStartPosition() > 1) {
         $msg = $pager->getStartPosition() - 1 . ' skipped';
         $this->log('');
         $this->log($this->formatter->format($msg, array('fg' => 'yellow')));
     }
     $count = $pager->getStartPosition();
     foreach ($pager->getResults() as $result) {
         $this->processHit($result, $count, $options['verbose']);
         $count++;
     }
     if (0 < ($diff = $pager->getNbResults() - $pager->getEndPosition())) {
         $msg = $diff . ' remaining';
         $this->log('');
         $this->log($this->formatter->format($msg, array('fg' => 'yellow')));
     }
 }