当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Search_Lucene_Search_QueryParser::_instance方法代码示例

本文整理汇总了PHP中Zend_Search_Lucene_Search_QueryParser::_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Search_QueryParser::_instance方法的具体用法?PHP Zend_Search_Lucene_Search_QueryParser::_instance怎么用?PHP Zend_Search_Lucene_Search_QueryParser::_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Search_Lucene_Search_QueryParser的用法示例。


在下文中一共展示了Zend_Search_Lucene_Search_QueryParser::_instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getInstance

 /**
  * Get query parser instance
  *
  * @return Zend_Search_Lucene_Search_QueryParser
  */
 private static function _getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
开发者ID:sepano,项目名称:open-social-media-monitoring,代码行数:12,代码来源:QueryParser.php

示例2: parse

 /**
  * Parses a query string
  *
  * @param string $strQuery
  * @param string $encoding
  * @return Zend_Search_Lucene_Search_Query
  * @throws Zend_Search_Lucene_Search_QueryParserException
  */
 public static function parse($strQuery, $encoding = null)
 {
     if (self::$_instance === null) {
         self::$_instance = new Zend_Search_Lucene_Search_QueryParser();
     }
     self::$_instance->_encoding = $encoding !== null ? $encoding : self::$_instance->_defaultEncoding;
     self::$_instance->_lastToken = null;
     self::$_instance->_context = new Zend_Search_Lucene_Search_QueryParserContext(self::$_instance->_encoding);
     self::$_instance->_contextStack = array();
     self::$_instance->_tokens = self::$_instance->_lexer->tokenize($strQuery, self::$_instance->_encoding);
     // Empty query
     if (count(self::$_instance->_tokens) == 0) {
         return new Zend_Search_Lucene_Search_Query_Empty();
     }
     foreach (self::$_instance->_tokens as $token) {
         try {
             self::$_instance->_currentToken = $token;
             self::$_instance->process($token->type);
             self::$_instance->_lastToken = $token;
         } catch (Exception $e) {
             if (strpos($e->getMessage(), 'There is no any rule for') !== false) {
                 throw new Zend_Search_Lucene_Search_QueryParserException('Syntax error at char position ' . $token->position . '.');
             }
             throw $e;
         }
     }
     if (count(self::$_instance->_contextStack) != 0) {
         throw new Zend_Search_Lucene_Search_QueryParserException('Syntax Error: mismatched parentheses, every opening must have closing.');
     }
     return self::$_instance->_context->getQuery();
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:39,代码来源:QueryParser.php


注:本文中的Zend_Search_Lucene_Search_QueryParser::_instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。