コード例 #1
0
 /**
  * @param string $queryString
  * @param array $options
  * @return \Elastica\Query
  */
 protected function buildQueryObject($queryString, $options)
 {
     // trying to match everything, make a MatchAll query
     if ($queryString == '*') {
         $queryObj = new \Elastica\Query\MatchAll();
     } else {
         $qString = html_entity_decode($queryString, ENT_QUOTES);
         // we need to escape slash for lucene query_string query
         $qString = str_replace('/', '\\/', $qString);
         $queryObj = new \Elastica\Query\QueryString($qString);
         $queryObj->setAnalyzeWildcard(true);
         $queryObj->setAutoGeneratePhraseQueries(false);
         // set query string fields
         $options['addSearchBoosts'] = true;
         $fields = $this->getSearchFields($options);
         $options['addSearchBoosts'] = false;
         if (!empty($options['searchFields'])) {
             $queryObj->setFields($options['searchFields']);
         } else {
             $queryObj->setFields($fields);
         }
     }
     return $queryObj;
 }