当前位置: 首页>>代码示例>>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;未经允许,请勿转载。