addQueryFieldPhrase() public method

Set the search phrase for a field.
public addQueryFieldPhrase ( $field, $searchPhrase )
$field string
$searchPhrase string
 /**
  * SCENARIO: re-index one journal (CLI)
  *   GIVEN I am on the command line
  *    WHEN I execute the tools/rebuildSearchIndex.php script
  *     AND I enter the path of a journal as command line argument
  *    THEN all articles of that journal will be deleted from
  *         the index and then re-indexed.
  *
  * SCENARIO: re-index all journals (CLI)
  *   GIVEN I am on the command line
  *    WHEN I execute the tools/rebuildSearchIndex.php script
  *         without parameters
  *    THEN all articles of all journals of the installation will
  *         be deleted from the index and then re-indexed.
  */
 public function testReindexJournalsByCli()
 {
     // Delete all documents from the index. As we use the embedded server
     // for testint we can use the well-known service parameters.
     import('plugins/generic/lucene/classes/SolrWebService');
     $solrWebService = new SolrWebService('http://localhost:8983/solr/ojs/search', 'admin', 'please change', 'test-inst');
     $solrWebService->deleteArticlesFromIndex(1);
     $solrWebService->deleteArticlesFromIndex(2);
     $searchRequest = new SolrSearchRequest();
     $searchRequest->addQueryFieldPhrase('query', '*:*');
     $totalResults = null;
     $solrWebService->retrieveResults($searchRequest, $totalResults);
     self::assertEquals(0, $totalResults);
     // Assemble the command line script name.
     $scriptName = Core::getBaseDir() . '/tools/rebuildSearchIndex.php -d';
     // Execute the script for one journal only.
     $output = null;
     exec("php {$scriptName} test", $output);
     // Check the script output.
     $expectedOutput = array('LucenePlugin: Clearing index \\.\\.\\. done', 'LucenePlugin: Indexing "test" \\. [0-9]+ articles indexed', 'LucenePlugin: Rebuilding dictionaries \\.\\.\\. done');
     foreach ($output as $outputLine) {
         $expectedRegex = array_shift($expectedOutput);
         self::assertRegExp("/{$expectedRegex}/", $outputLine);
     }
     // Check the index.
     $solrWebService->retrieveResults($searchRequest, $totalResults);
     self::assertGreaterThan(0, $totalResults);
     self::assertLessThan(37, $totalResults);
     // Execute the script for all journals.
     $output = null;
     exec("php {$scriptName}", $output);
     // Check the script output.
     $expectedOutput = array('LucenePlugin: Clearing index \\.\\.\\. done', 'LucenePlugin: Indexing "lucene-test" \\. [0-9]+ articles indexed', 'LucenePlugin: Indexing "test" \\. [0-9]+ articles indexed');
     foreach ($output as $outputLine) {
         $expectedRegex = array_shift($expectedOutput);
         self::assertRegExp("/{$expectedRegex}/", $outputLine);
     }
     // Rebuild the dictionaries only
     $output = null;
     exec("php {$scriptName} -d -n", $output);
     // Check the script output.
     $expectedRegex = 'LucenePlugin: Rebuilding dictionaries \\.\\.\\. done';
     self::assertEquals(1, count($output));
     self::assertRegExp("/{$expectedRegex}/", array_shift($output));
     // Check the index.
     $solrWebService->retrieveResults($searchRequest, $totalResults);
     self::assertGreaterThanOrEqual(37, $totalResults);
 }