本文整理汇总了PHP中Zend_Search_Lucene_Analysis_Analyzer::setDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Analysis_Analyzer::setDefault方法的具体用法?PHP Zend_Search_Lucene_Analysis_Analyzer::setDefault怎么用?PHP Zend_Search_Lucene_Analysis_Analyzer::setDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Search_Lucene_Analysis_Analyzer
的用法示例。
在下文中一共展示了Zend_Search_Lucene_Analysis_Analyzer::setDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construct, create index
*
* @param string $indexPath[optional]
* @param string $encoding[optional]
* @throws Axis_Exception
*/
public function __construct(array $params)
{
$encoding = $this->_encoding;
$indexPath = array_shift($params);
if (count($params)) {
$encoding = array_shift($params);
}
if (null === $indexPath) {
$site = Axis::getSite()->id;
$locale = Axis::single('locale/language')->find(Axis_Locale::getLanguageId())->current()->locale;
$indexPath = Axis::config()->system->path . '/var/index/' . $site . '/' . $locale;
}
if (!is_readable($indexPath)) {
throw new Axis_Exception(Axis::translate('search')->__('Please, update search indexes, to enable search functionality'));
}
/*
$mySimilarity = new Axis_Similarity();
Zend_Search_Lucene_Search_Similarity::setDefault($mySimilarity);
*/
Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding($encoding);
// add filter by words
$stopWords = array('a', 'an', 'at', 'the', 'and', 'or', 'is', 'am');
$stopWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords);
$analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
$analyzer->addFilter($stopWordsFilter);
Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
$this->_index = Zend_Search_Lucene::open($indexPath);
$this->_encoding = $encoding;
}
示例2: 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];
}
示例3: buildplaces
public function buildplaces()
{
ini_set('memory_limit', '1000M');
set_time_limit(0);
$time = time();
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
/**
* Create index
*/
$index = Zend_Search_Lucene::create($this->_indexPath);
/**
* Get all users
*/
$sql = $this->_db->select()->from($this->_name, array('id', 'name', 'placepic'))->limit(7500);
$result = $this->_db->fetchAssoc($sql);
foreach ($result as $values) {
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::keyword('placeid', $values['id']));
$doc->addField(Zend_Search_Lucene_Field::text('placename', $values['name']));
$doc->addField(Zend_Search_Lucene_Field::unStored('placepic', $values['placepic']));
$index->addDocument($doc);
}
$index->commit();
$elapsed = time() - $time;
print_r($elapsed);
}
示例4: __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
}
示例5: __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());
}
示例6: update
public static function update($data)
{
try {
//Update an index.
$index = Zend_Search_Lucene::open('../application/searchindex');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
} catch (Zend_Search_Exception $e) {
throw $e;
}
// remove an existing entry
$hits = $index->find('pk:' . $data['pk']);
foreach ($hits as $hit) {
$index->delete($hit->id);
}
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('pk', $data['pk']));
$doc->addField(Zend_Search_Lucene_Field::Keyword('code', $data['code'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Keyword('u_code', strtolower($data['code']), 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::unIndexed('type', $data['type'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::unIndexed('id', $data['id'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title', $data['title'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('en_title', Default_Model_Functions::convert_vi_to_en($data['title']), 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('description', $data['description'], 'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('en_description', Default_Model_Functions::convert_vi_to_en($data['description']), 'UTF-8'));
$index->addDocument($doc);
$index->commit();
}
示例7: luceneSearchAction
public function luceneSearchAction()
{
$this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$path = PUBLIC_PATH . '/tmp/lucene';
$index = Zend_Search_Lucene::open($path);
// $term = new Zend_Search_Lucene_Index_Term('ritesh','title');
// $subquery1 = new Zend_Search_Lucene_Search_Query_Term($term);
//
// $from = new Zend_Search_Lucene_Index_Term('0', 'empcode');
// $to = new Zend_Search_Lucene_Index_Term('53', 'empcode');
// $subquery2 = new Zend_Search_Lucene_Search_Query_Range($from, $to, true);
//
// $query = new Zend_Search_Lucene_Search_Query_Boolean();
// $query->addSubquery($subquery1, true );
// $query->addSubquery($subquery2, null );
// Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
// $hits = $index->find($query);
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength(1);
$hits = $index->find("empcode:[000 TO 200]");
foreach ($hits as $h) {
echo "Title:" . $h->title;
echo "-------EmpCode:" . $h->empcode;
echo "<br>";
}
}
示例8: __construct
/**
* Searchengine::__construct()
*
* @return
*/
public function __construct()
{
parent::__construct();
$this->search_index = APPPATH . 'cache/search_index/index';
$this->load->library('zend');
$this->zend->load('Zend/Search/Lucene');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
}
示例9: init
public function init()
{
if (is_file(TEMP_PATH . '/Search/write.lock.file')) {
$this->_indexHandle = Zend_Search_Lucene::open(TEMP_PATH . '/Search');
} else {
$this->_indexHandle = Zend_Search_Lucene::create(TEMP_PATH . '/Search');
}
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
}
示例10: __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());
}
示例11: open_writable_database
/**
* Initialise a writable database for updating the index
*
* @param int flag allow setting the DB to be initialised with PluginSearchInterface::INIT_DB
*/
public function open_writable_database($flag = 0)
{
Zend_Search_Lucene::setResultSetLimit(50);
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
if (PluginSearchInterface::INIT_DB == $flag) {
$this->_index = Zend_Search_Lucene::create($this->_index_path);
} else {
$this->_index = Zend_Search_Lucene::open($this->_index_path);
}
}
示例12: testAnalyzer
public function testAnalyzer()
{
$currentAnalyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault();
$this->assertTrue($currentAnalyzer instanceof Zend_Search_Lucene_Analysis_Analyzer);
$newAnalyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num();
Zend_Search_Lucene_Analysis_Analyzer::setDefault($newAnalyzer);
$this->assertTrue(Zend_Search_Lucene_Analysis_Analyzer::getDefault() === $newAnalyzer);
// Set analyzer to the default value (used in other tests)
Zend_Search_Lucene_Analysis_Analyzer::setDefault($currentAnalyzer);
}
示例13: getLuceneIndex
public static function getLuceneIndex()
{
ProjectConfiguration::registerZend();
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
if (file_exists($index = self::getLuceneIndexFile())) {
return Zend_Search_Lucene::open($index);
} else {
return Zend_Search_Lucene::create($index);
}
}
示例14: 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();
self::$zendLoaded = true;
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
}
示例15: __construct
function __construct($directory, $lang = 'en', $highlight = true)
{
switch ($lang) {
case 'en':
default:
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new StandardAnalyzer_Analyzer_Standard_English());
}
$this->directory = $directory;
$this->lastModif = file_exists($directory) ? filemtime($directory) : 0;
$this->highlight = (bool) $highlight;
}