/**
  * 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')));
     }
 }
require 'lexer/lucene/xfLexemeLucene.class.php';
require 'lexer/lucene/xfLexemeBuilderLuceneAddSyntax.class.php';
require 'criteria/xfCriterion.interface.php';
require 'criteria/xfCriterionEmpty.class.php';
require 'criteria/xfCriteria.class.php';
require 'criteria/xfCriterionTerm.class.php';
require 'criteria/xfCriterionPhrase.class.php';
require 'criteria/xfCriterionRange.class.php';
require 'criteria/xfCriterionWildcard.class.php';
require 'criteria/xfCriterionDecorator.class.php';
require 'criteria/xfCriterionField.class.php';
require 'criteria/xfCriterionProhibited.class.php';
require 'criteria/xfCriterionRequired.class.php';
require 'criteria/xfCriterionBoost.class.php';
$t = new lime_test(50, new lime_output_color());
$parser = new xfParserLucene();
$p = new xfParserTester($t, $parser);
$t->diag('Empty');
$p->pass('', 'EMPTY');
$p->pass('            ', 'EMPTY');
$t->diag('Term');
$p->pass('foo', 'foo');
$t->diag('Boolean');
$p->pass('foo bar baz', 'BOOLEAN {[foo] AND [bar] AND [baz]}');
$p->pass('foo and bar', 'BOOLEAN {[REQUIRED {foo}] AND [REQUIRED {bar}]}');
$p->pass('foo or bar', 'BOOLEAN {[foo] AND [bar]}');
$t->diag('Phrase');
$p->pass('"foo bar baz"', 'PHRASE {"foo bar baz"}');
$p->pass('"foo bar" "baz gab"', 'BOOLEAN {[PHRASE {"foo bar"}] AND [PHRASE {"baz gab"}]}');
$p->pass('"foo bar"~10', 'PHRASE {"foo bar" SLOP 10}');
$p->pass('+"foo bar"~2', 'REQUIRED {PHRASE {"foo bar" SLOP 2}}');