當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions方法代碼示例

本文整理匯總了PHP中Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions方法的具體用法?PHP Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions怎麽用?PHP Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Search_Lucene_Search_QueryParser的用法示例。


在下文中一共展示了Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testQueryParserExceptionsHandling

 public function testQueryParserExceptionsHandling()
 {
     $this->assertTrue(Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed());
     try {
         $query = Zend_Search_Lucene_Search_QueryParser::parse('contents:[business TO by}');
     } catch (Zend_Search_Lucene_Exception $e) {
         $this->fail('exception raised while parsing a query');
     }
     $this->assertEquals('contents business to by', $query->__toString());
     Zend_Search_Lucene_Search_QueryParser::dontSuppressQueryParsingExceptions();
     $this->assertFalse(Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed());
     try {
         $query = Zend_Search_Lucene_Search_QueryParser::parse('contents:[business TO by}');
         $this->fail('exception wasn\'t raised while parsing a query');
     } catch (Zend_Search_Lucene_Exception $e) {
         $this->assertEquals('Syntax error at char position 25.', $e->getMessage());
     }
     Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions();
     $this->assertTrue(Zend_Search_Lucene_Search_QueryParser::queryParsingExceptionsSuppressed());
 }
開發者ID:ThorstenSuckow,項目名稱:conjoon,代碼行數:20,代碼來源:Search23Test.php

示例2: get_lucene_query

 /**
  * Трансформация запроса nc_search_query в запрос Lucene
  * @param nc_search_query $query
  * @return Zend_Search_Lucene_Search_Query
  */
 protected function get_lucene_query(nc_search_query $query)
 {
     Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions();
     if ($this->get_setting('DefaultBooleanOperator') == 'AND') {
         Zend_Search_Lucene_Search_QueryParser::setDefaultOperator(Zend_Search_Lucene_Search_QueryParser::B_AND);
     }
     $query_string = $query->to_string();
     // range search for integers
     if (nc_search::should('AllowRangeSearch') && strpos($query_string, ' TO ')) {
         preg_match_all("/(\\[|\\{)\\s*(\\d+)\\s+TO\\s+(\\d+)\\s*(\\]|\\})/", $query_string, $matches, PREG_SET_ORDER);
         foreach ($matches as $m) {
             $query_string = str_replace($m[0], $m[1] . $this->pad_integer($m[2]) . " TO " . $this->pad_integer($m[3]) . $m[4], $query_string);
         }
     }
     // add a time range should it be required
     $modified_after = $query->get('modified_after');
     $modified_before = $query->get('modified_before');
     if ($modified_before || $modified_after) {
         $modified_after = $modified_after ? strftime("%Y%m%d%H%M%S", strtotime($modified_after)) : "19000101000000";
         $modified_before = $modified_before ? strftime("%Y%m%d%H%M%S", strtotime($modified_before)) : "22000101000000";
         $query_string = "({$query_string}) last_modified:[{$modified_after} TO {$modified_before}]";
     }
     // add area
     $area = $query->get('area');
     if ($area) {
         if (!$area instanceof nc_search_area) {
             $area = new nc_search_area($area);
         }
         $is_boolean = nc_search_util::is_boolean_query($query_string);
         $query_string = "({$query_string}) " . ($is_boolean ? " AND " : "+") . $area->get_field_condition($is_boolean);
     }
     // parse string into Lucene Query
     $zend_query = Zend_Search_Lucene_Search_QueryParser::parse($query_string, 'UTF-8');
     return $zend_query;
 }
開發者ID:Blu2z,項目名稱:implsk,代碼行數:40,代碼來源:zend.php


注:本文中的Zend_Search_Lucene_Search_QueryParser::suppressQueryParsingExceptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。