本文整理汇总了PHP中Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding方法的具体用法?PHP Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding怎么用?PHP Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Search_Lucene_Search_QueryParser
的用法示例。
在下文中一共展示了Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* Returns Zend_Search_Lucene instance for given subroot
*
* every subroot has it's own instance
*
* @param Kwf_Component_Data for this index
* @return Zend_Search_Lucene_Interface
*/
public static function getInstance(Kwf_Component_Data $subroot)
{
while ($subroot) {
if (Kwc_Abstract::getFlag($subroot->componentClass, 'subroot')) {
break;
}
$subroot = $subroot->parent;
}
if (!$subroot) {
$subroot = Kwf_Component_Data_Root::getInstance();
}
static $instance = array();
if (!isset($instance[$subroot->componentId])) {
$analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords(2));
//$stopWords = explode(' ', 'der dir das einer eine ein und oder doch ist sind an in vor nicht wir ihr sie es ich');
//$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords));
Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0666);
$path = 'cache/fulltext';
$path .= '/' . $subroot->componentId;
try {
$instance[$subroot->componentId] = Zend_Search_Lucene::open($path);
} catch (Zend_Search_Lucene_Exception $e) {
$instance[$subroot->componentId] = Zend_Search_Lucene::create($path);
}
}
return $instance[$subroot->componentId];
}
示例2: __construct
public function __construct()
{
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
//set default encoding
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_CJK());
//set default Analyzer
}
示例3: __construct
/**
* Creates a new ZendLucene handler connection
*
* @param string $location
*/
public function __construct($location)
{
/**
* We're using realpath here because Zend_Search_Lucene does not do
* that itself. It can cause issues because their destructor uses the
* same filename but the cwd could have been changed.
*/
$location = realpath($location);
/* If the $location doesn't exist, ZSL throws a *generic* exception. We
* don't care here though and just always assume it is because the
* index does not exist. If it doesn't exist, we create it.
*/
try {
$this->connection = Zend_Search_Lucene::open($location);
} catch (Zend_Search_Lucene_Exception $e) {
$this->connection = Zend_Search_Lucene::create($location);
}
$this->inTransaction = 0;
if (!$this->connection) {
throw new ezcSearchCanNotConnectException('zendlucene', $location);
}
// Set proper default encoding for query parser
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
}
示例4: __construct
public function __construct()
{
$this->_log()->info('Starting up');
if (@preg_match('/\\pL/u', 'a') != 1) {
$this->_log()->err("PCRE unicode support is turned off.\n");
}
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding($this->_encoding);
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
}
示例5: __construct
public function __construct()
{
try {
parent::__construct(new Zend_Search_Lucene(self::INDEX_DIR, false));
} catch (Zend_Search_Lucene_Exception $e) {
parent::__construct(new Zend_Search_Lucene(self::INDEX_DIR, true));
}
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding("UTF-8");
}
示例6: renewIndex
public static function renewIndex($forceCreate = false)
{
$pages = Application_Model_Mappers_PageMapper::getInstance()->getPagesForSearchIndex();
if (!is_array($pages)) {
return false;
}
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
self::removeIndex() && self::initIndex();
array_walk($pages, array('Tools_Search_Tools', 'addPageToIndex'));
self::$_index->optimize();
}
示例7: registerZend
public static function registerZend()
{
if (self::$zendLoaded) {
return;
}
set_include_path(sfConfig::get('sf_lib_dir') . '/vendor' . PATH_SEPARATOR . get_include_path());
require_once sfConfig::get('sf_lib_dir') . '/vendor/Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
self::$zendLoaded = true;
}
示例8: actionSearch
public function actionSearch()
{
$indexFiles = Yii::app()->getModule('zendsearch')->indexFiles;
SetLocale(LC_ALL, 'ru_RU.UTF-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
if (($term = Yii::app()->getRequest()->getQuery('q', null)) !== null) {
$index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $indexFiles));
$results = $index->find($term);
$query = Zend_Search_Lucene_Search_QueryParser::parse($term);
$this->render('search', compact('results', 'term', 'query'));
}
}
示例9: __construct
function __construct($directory, $lang = 'en', $highlight = true)
{
switch ($lang) {
case 'en':
default:
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new StandardAnalyzer_Analyzer_Standard_English());
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
}
Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0660);
$this->directory = $directory;
$this->lastModif = file_exists($directory) ? filemtime($directory) : 0;
$this->highlight = (bool) $highlight;
}
示例10: SiteSearch
/**
* Constructor method.
*/
function SiteSearch()
{
if (!@file_exists($this->path . '/segments')) {
$this->client = new Zend_Search_Lucene($this->path, true);
} else {
$this->client = new Zend_Search_Lucene($this->path);
}
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
ini_set('iconv.input_encoding', 'utf-8');
ini_set('iconv.internal_encoding', 'utf-8');
ini_set('iconv.output_encoding', 'utf-8');
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
umask(00);
}
示例11: getInstance
/**
*
* @return Zend_Search_Lucene_Interface
*/
public static function getInstance()
{
if (self::$_instance === NULL) {
$indexDir = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'lucene';
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
try {
$index = Zend_Search_Lucene::open($indexDir);
} catch (Exception $e) {
$index = Zend_Search_Lucene::create($indexDir);
}
self::$_instance = $index;
}
return self::$_instance;
}
示例12: __construct
public function __construct($config)
{
$this->indexFile = $config['indexFile'];
$this->__setSources($config['source']);
$this->indexDirectory = TMP;
if (!empty($config['indexDirectory'])) {
$this->indexDirectory = $config['indexDirectory'];
}
$this->__loadIndex($this->indexDirectory . $this->indexFile);
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding(strtolower(Configure::read('App.encoding')));
if (!empty($config['analyzer'])) {
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new $config['analyzer']());
}
parent::__construct($config);
}
示例13: __construct
public function __construct()
{
if (file_exists("Joobsbox/SearchIndexes/main")) {
$this->_index = Zend_Search_Lucene::open("Joobsbox/SearchIndexes/main");
} else {
if (is_writable('Joobsbox/SearchIndexes')) {
$this->_index = Zend_Search_Lucene::create("Joobsbox/SearchIndexes/main");
} else {
$this->_enabled = false;
}
}
if ($this->_enabled) {
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
}
}
示例14: __construct
/**
* Initializes search model. If a Zend_Search_Lucene index is not found, one is created in /Joobsbox/SearchIndexes
*/
public function __construct()
{
$this->_path = APPLICATION_DIRECTORY . "/Joobsbox/SearchIndexes/";
if (file_exists($this->_path . "main")) {
$this->index = Zend_Search_Lucene::open($this->_path . "main");
} else {
if (is_writable($this->_path)) {
$this->index = Zend_Search_Lucene::create($this->_path . "main");
} else {
$this->enabled = false;
}
}
if ($this->enabled) {
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
}
}
示例15: get_Zend_Search_Lucene
public function get_Zend_Search_Lucene($create_new_index = FALSE)
{
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
if (self::$_indexer != NULL) {
return self::$_indexer;
}
$search_lucene_directory = $this->CI->config->item('search_lucene_directory');
$dir_path = $_SERVER['DOCUMENT_ROOT'] . $search_lucene_directory;
//var_dump($dir_path); exit;
//ApplicationHook::logInfo($dir_path);
$files = get_filenames($dir_path);
if (count($files) <= 1) {
//not found index files, index as new
$create_new_index = TRUE;
}
if ($create_new_index) {
self::$_indexer = Zend_Search_Lucene::create($dir_path, TRUE);
} else {
self::$_indexer = Zend_Search_Lucene::open($dir_path);
}
return self::$_indexer;
}