예제 #1
0
파일: Index.php 프로젝트: linuxwhy/tiki-1
 private function getLucene()
 {
     if ($this->lucene) {
         return $this->lucene;
     }
     try {
         $this->lucene = ZendSearch\Lucene\Lucene::open($this->directory);
     } catch (ZendSearch\Lucene\Exception\ExceptionInterface $e) {
         $this->lucene = ZendSearch\Lucene\Lucene::create($this->directory);
     }
     global $prefs;
     if (!empty($prefs['unified_lucene_max_buffered_docs'])) {
         // these break indexing if set empty
         $this->lucene->setMaxBufferedDocs($prefs['unified_lucene_max_buffered_docs']);
         // default is 10
     }
     if (!empty($prefs['unified_lucene_max_merge_docs'])) {
         $this->lucene->setMaxMergeDocs($prefs['unified_lucene_max_merge_docs']);
         // default is PHP_INT_MAX (effectively "infinite")
     }
     if (!empty($prefs['unified_lucene_merge_factor'])) {
         $this->lucene->setMergeFactor($prefs['unified_lucene_merge_factor']);
         // default is 10
     }
     ZendSearch\Lucene\Lucene::setResultSetLimit($this->resultSetLimit);
     return $this->lucene;
 }
예제 #2
0
 /**
  * @return Search_Index_Interface
  */
 function getIndex($indexType = 'data')
 {
     global $prefs, $tiki_p_admin;
     $writeMode = false;
     if ($indexType == 'data-write') {
         $indexType = 'data';
         $writeMode = true;
     }
     switch ($prefs['unified_engine']) {
         case 'lucene':
             ZendSearch\Lucene\Lucene::setTermsPerQueryLimit($prefs['unified_lucene_terms_limit']);
             $index = new Search_Lucene_Index($this->getIndexLocation($indexType), $prefs['language'], $prefs['unified_lucene_highlight'] == 'y');
             $index->setCache(TikiLib::lib('cache'));
             $index->setMaxResults($prefs['unified_lucene_max_result']);
             $index->setResultSetLimit($prefs['unified_lucene_max_resultset_limit']);
             return $index;
         case 'elastic':
             $index = $this->getIndexLocation($indexType);
             if (empty($index)) {
                 break;
             }
             $connection = $this->getElasticConnection($writeMode);
             $index = new Search_Elastic_Index($connection, $index);
             $index->setCamelCaseEnabled($prefs['unified_elastic_camel_case'] == 'y');
             $index->setFacetCount($prefs['search_facet_default_amount']);
             return $index;
         case 'mysql':
             $index = $this->getIndexLocation($indexType);
             if (empty($index)) {
                 break;
             }
             $index = new Search_MySql_Index(TikiDb::get(), $index);
             return $index;
     }
     // Do nothing, provide a fake index.
     $errlib = TikiLib::lib('errorreport');
     if ($tiki_p_admin != 'y') {
         $errlib->report(tr('Contact the site administrator. The index needs rebuilding.'));
     } else {
         $errlib->report('<a title="' . tr("Rebuild search index") . '" href="tiki-admin.php?page=search&rebuild=now">' . tr("Click here to rebuild index") . '</a>');
     }
     return new Search_Index_Memory();
 }
예제 #3
0
파일: Server.php 프로젝트: rjsmelo/tiki
 private function getIndex($rebuld = false)
 {
     if ($rebuld || $this->indexNeedsRebuilding()) {
         $index = ZendSearch\Lucene\Lucene::create($this->indexFile);
         foreach ($this->getReceivedDataLatest() as $connection) {
             $data = json_decode($connection['data'], true);
             if ($data) {
                 $doc = $this->indexConnection($connection['created'], $data);
                 $index->addDocument($doc);
             }
         }
         $index->optimize();
         return $index;
     }
     return ZendSearch\Lucene\Lucene::open($this->indexFile);
 }