示例#1
0
 /**
  * Returns the string used to build out a boost query with Solarium
  * @see    WikiaSearchTest::testGetBoostQueryString
  * @param  WikiaSearchConfig $searchConfig
  * @return string
  */
 private function getBoostQueryString(WikiaSearchConfig $searchConfig)
 {
     $queryNoQuotes = $searchConfig->getQueryNoQuotes(true);
     if ($searchConfig->isInterWiki()) {
         $queryNoQuotes = preg_replace('/ wiki\\b/i', '', $queryNoQuotes);
     }
     $boostQueries = array(self::valueForField('html', $queryNoQuotes, array('boost' => 5, 'quote' => '\\"')), self::valueForField('title', $queryNoQuotes, array('boost' => 10, 'quote' => '\\"')));
     if ($searchConfig->isInterWiki()) {
         $boostQueries[] = self::valueForField('wikititle', $queryNoQuotes, array('boost' => 15, 'quote' => '\\"'));
         $boostQueries[] = self::valueForField('host', 'answers', array('boost' => 10, 'negate' => true));
         $boostQueries[] = self::valueForField('host', 'respuestas', array('boost' => 10, 'negate' => true));
     }
     return implode(' ', $boostQueries);
 }