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


PHP Zend_Search_Lucene_Storage_Directory_Filesystem类代码示例

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


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

示例1: testFilesystemSubfoldersAutoCreation

 public function testFilesystemSubfoldersAutoCreation()
 {
     $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_tempFiles/_files/dir1/dir2/dir3');
     $this->assertTrue($directory instanceof Zend_Search_Lucene_Storage_Directory);
     $directory->close();
     rmdir(dirname(__FILE__) . '/_tempFiles/_files/dir1/dir2/dir3');
     rmdir(dirname(__FILE__) . '/_tempFiles/_files/dir1/dir2');
     rmdir(dirname(__FILE__) . '/_tempFiles/_files/dir1');
 }
开发者ID:lortnus,项目名称:zf1,代码行数:9,代码来源:DirectoryTest.php

示例2: testCreate

 public function testCreate()
 {
     $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_files/_source');
     $stiFile = $directory->getFileObject('_1.sti');
     $stiFileData = $stiFile->readBytes($directory->fileLength('_1.sti'));
     // Load dictionary index data
     list($termDictionary, $termDictionaryInfos) = unserialize($stiFileData);
     $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo('_1', 2, $directory);
     $tiiFile = $segmentInfo->openCompoundFile('.tii');
     $tiiFileData = $tiiFile->readBytes($segmentInfo->compoundFileLength('.tii'));
     // Load dictionary index data
     list($loadedTermDictionary, $loadedTermDictionaryInfos) = Zend_Search_Lucene_Index_DictionaryLoader::load($tiiFileData);
     $this->assertTrue($termDictionary == $loadedTermDictionary);
     $this->assertTrue($termDictionaryInfos == $loadedTermDictionaryInfos);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:15,代码来源:DictionaryLoaderTest.php

示例3: 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];
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:38,代码来源:Lucene.php

示例4: __construct

 /**
  * Constructor to set initial values.
  *
  * @param string $location The index location
  */
 public function __construct($location)
 {
     $this->location = $location;
     $this->analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
     require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php';
     Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0666);
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:12,代码来源:xfLuceneEngine.class.php

示例5: __construct

 public function __construct()
 {
     $index_path = BUGDAR_ROOT . '/cache/lucene_index';
     Zend_Search_Lucene_Storage_Directory_Filesystem::SetDefaultFilePermissions(0777);
     if (file_exists($index_path)) {
         $this->lucene = Zend_Search_Lucene::Open($index_path);
     } else {
         $this->lucene = Zend_Search_Lucene::Create($index_path);
     }
 }
开发者ID:rsesek,项目名称:Bugdar2,代码行数:10,代码来源:search_engine.php

示例6: testMerge

    public function testMerge()
    {
        $segmentsDirectory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_files/_source');
        $outputDirectory   = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_files');
        $segmentsList = array('_0', '_1', '_2', '_3', '_4');

        $segmentMerger = new Zend_Search_Lucene_Index_SegmentMerger($outputDirectory, 'mergedSegment');

        foreach ($segmentsList as $segmentName) {
            $segmentMerger->addSource(new Zend_Search_Lucene_Index_SegmentInfo($segmentName, 2, $segmentsDirectory));
        }

        $mergedSegment = $segmentMerger->merge();
        $this->assertTrue($mergedSegment instanceof Zend_Search_Lucene_Index_SegmentInfo);
        unset($mergedSegment);

        $mergedFile = $outputDirectory->getFileObject('mergedSegment.cfs');
        $mergedFileData = $mergedFile->readBytes($outputDirectory->fileLength('mergedSegment.cfs'));

        $sampleFile = $outputDirectory->getFileObject('mergedSegment.cfs.sample');
        $sampleFileData = $sampleFile->readBytes($outputDirectory->fileLength('mergedSegment.cfs.sample'));

        $this->assertEquals($mergedFileData, $sampleFileData);

        $outputDirectory->deleteFile('mergedSegment.cfs');
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:26,代码来源:SegmentMergerTest.php

示例7: __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;
 }
开发者ID:jkimdon,项目名称:cohomeals,代码行数:13,代码来源:Index.php

示例8: prepareZendSearchLucene

  private static function prepareZendSearchLucene()
  {
    Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());

    $stopWords = sfConfig::get('app_sf_propel_luceneable_behavior_stopWords', false);
    $stopWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_StopWords(false === $stopWords ? array() : explode(',', $stopWords));
    Zend_Search_Lucene_Analysis_Analyzer::getDefault()->addFilter($stopWordsFilter);

    $shortWords = sfConfig::get('app_sf_propel_luceneable_behavior_shortWords', 3);
    $shortWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords($shortWords);
    Zend_Search_Lucene_Analysis_Analyzer::getDefault()->addFilter($shortWordsFilter);

    Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0777);
  }
开发者ID:nibsirahsieu,项目名称:sfPropelLuceneableBehaviorPlugin,代码行数:14,代码来源:sfLuceneableToolkit.class.php

示例9: searchAction

 public function searchAction()
 {
     $form = new Application_Form_Search();
     $this->view->form = $form;
     $form->submit->setLabel('search jobs');
     $currentPermissions = Zend_Search_Lucene_Storage_Directory_Filesystem::getDefaultFilePermissions();
     echo $currentPermissions;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($_POST)) {
             $query = $form->getValue('query');
             $index = Zend_Search_Lucene::open('C:\\indexed');
             $hits = $index->find($query);
             $this->view->jobs = $hits;
             // foreach ($hits as $hit) {
             //echo $hit->pri;
             //echo $hit->shortd;
             //}
         } else {
             $form->populate($formData);
         }
     }
 }
开发者ID:sk16,项目名称:jobPortal,代码行数:23,代码来源:NewappController.php

示例10: __construct

 /**
  * Indexer Constructor.
  * 
  * @global type $webDir
  */
 public function __construct()
 {
     global $webDir;
     if (!get_config('enable_indexing')) {
         return;
     }
     $index_path = $webDir . self::$_index_dir;
     // Give read-writing permissions only for current user and group
     Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0600);
     // Utilize UTF-8 compatible text analyzer
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
     try {
         if (file_exists($index_path)) {
             $this->__index = Zend_Search_Lucene::open($index_path);
             // Open index
         } else {
             $this->__index = Zend_Search_Lucene::create($index_path);
             // Create index
         }
     } catch (Zend_Search_Lucene_Exception $e) {
         require_once 'fatal_error.php';
     }
     $this->__index->setFormatVersion(Zend_Search_Lucene::FORMAT_2_3);
     // Set Index Format Version
     Zend_Search_Lucene::setResultSetLimit(self::$_resultSetLimit);
     // Set Result Set Limit
     // write an .htaccess to prevent raw access to index files
     $htaccess = $index_path . '/.htaccess';
     if (!file_exists($htaccess)) {
         $fd = fopen($htaccess, "w");
         fwrite($fd, "deny from all\n");
         fclose($fd);
     }
     if (!file_exists($index_path . '/index.php')) {
         touch($index_path . '/index.php');
     }
 }
开发者ID:kostastzo,项目名称:openeclass,代码行数:42,代码来源:indexer.class.php

示例11: testDelete

 public function testDelete()
 {
     $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files');
     $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, 0);
     $this->assertFalse($segmentInfo->hasDeletions());
     $segmentInfo->delete(0);
     $this->assertTrue($segmentInfo->hasDeletions());
     $delGen = $segmentInfo->getDelGen();
     // don't write changes
     unset($segmentInfo);
     $segmentInfo1 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, $delGen);
     // Changes wasn't written, segment still has no deletions
     $this->assertFalse($segmentInfo1->hasDeletions());
     $segmentInfo1->delete(0);
     $segmentInfo1->writeChanges();
     $delGen = $segmentInfo1->getDelGen();
     unset($segmentInfo1);
     $segmentInfo2 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, $delGen);
     $this->assertTrue($segmentInfo2->hasDeletions());
     unset($segmentInfo2);
     $directory->deleteFile('_1_' . base_convert($delGen, 10, 36) . '.del');
     $segmentInfo3 = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2, -1);
     $this->assertFalse($segmentInfo3->hasDeletions());
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:24,代码来源:SegmentInfoTest.php

示例12: _index

 /**
  * Instanciate the Lucene index
  * 
  * The index will be created if it doesn't exist yet.
  * 
  * @return \Zend_Search_Lucene_Interface							Lucene index instance
  * @throws Exception											If the index cannot be created
  */
 protected function _index()
 {
     // One-time instanciation or creation of the lucene index
     if ($this->_index === null) {
         // Try to instanciate an existing lucene index
         try {
             $this->_index = \Zend_Search_Lucene::open($this->_indexDirectory);
             // If an error occurs ...
         } catch (\Zend_Search_Lucene_Exception $e) {
             // Try to create a new lucene index ...
             try {
                 $this->_index = \Zend_Search_Lucene::create($this->_indexDirectory);
                 // If an error occurs: Failure
             } catch (\Zend_Search_Lucene_Exception $e) {
                 throw new Exception(sprintf('Error creating lucene index in "%1$s", reason: "%2$s"', $this->_indexDirectory, $e->getMessage()));
             }
         }
         // Index setup
         \Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0664);
         \Zend_Search_Lucene_Analysis_Analyzer::setDefault(new \Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
         \Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
         // Minimize memory consumption
         $this->_index->setMaxBufferedDocs(1);
         // Set optimization frequency
         $this->_index->setMergeFactor(max(1, intval($GLOBALS['TYPO3_CONF_VARS']['EXT']['extParams']['tw_lucenesearch']['mergeFactor'])));
         // If applicable: Optimize index
         if ($this->_indexOptimize) {
             $this->_index->optimize();
         }
         $this->_index->commit();
         if (TYPO3_MODE == 'FE') {
             \Zend_Search_Lucene::setTermsPerQueryLimit(\Tollwerk\TwLucenesearch\Utility\Indexer::indexConfig($GLOBALS['TSFE'], 'search.limits.query'));
         }
     }
     return $this->_index;
 }
开发者ID:GerDner,项目名称:TYPO3-ext-tw_lucenesearch,代码行数:44,代码来源:Lucene.php

示例13: writeChanges

 /**
  * Write changes if it's necessary.
  */
 public function writeChanges()
 {
     if (!$this->_deletedDirty) {
         return;
     }
     if (extension_loaded('bitset')) {
         $delBytes = $this->_deleted;
         $bitCount = count(bitset_to_array($delBytes));
     } else {
         $byteCount = floor($this->_docCount / 8) + 1;
         $delBytes = str_repeat(chr(0), $byteCount);
         for ($count = 0; $count < $byteCount; $count++) {
             $byte = 0;
             for ($bit = 0; $bit < 8; $bit++) {
                 if (isset($this->_deleted[$count * 8 + $bit])) {
                     $byte |= 1 << $bit;
                 }
             }
             $delBytes[$count] = chr($byte);
         }
         $bitCount = count($this->_deleted);
     }
     $delFile = $this->_directory->createFile($this->_name . '.del');
     $delFile->writeInt($this->_docCount);
     $delFile->writeInt($bitCount);
     $delFile->writeBytes($delBytes);
     $this->_deletedDirty = false;
 }
开发者ID:BackupTheBerlios,项目名称:openpublisher-svn,代码行数:31,代码来源:SegmentInfo.php

示例14: openCompoundFile

 /**
  * Opens index file stoted within compound index file
  *
  * @param string $extension
  * @throws Zend_Search_Lucene_Exception
  * @return Zend_Search_Lucene_Storage_File
  */
 public function openCompoundFile($extension)
 {
     $filename = $this->_name . $extension;
     if (!isset($this->_segFiles[$filename])) {
         throw new Zend_Search_Lucene_Exception('Index compound file doesn\'t contain ' . $filename . ' file.');
     }
     $file = $this->_directory->getFileObject($this->_name . ".cfs");
     $file->seek($this->_segFiles[$filename]);
     return $file;
 }
开发者ID:Nurudeen,项目名称:prado,代码行数:17,代码来源:SegmentInfo.php

示例15: createFile

 public function createFile($filename)
 {
     try {
         parent::createFile($filename);
     } catch (Zend_Search_Lucene_Exception $e) {
         if (false === strpos($e->getMessage(), 'chmod')) {
             throw $e;
         }
     }
     return $this->_fileHandlers[$filename];
 }
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:11,代码来源:xfLuceneEnhancedFilesystem.class.php


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