/**
  * 静态方法, 单例统一访问入口
  * @return object  返回对象的唯一实例
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance) || !isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Esempio n. 2
0
 /**
  *根据文件的Hash值报告索引成功
  * @param string $signature 文件hash值
  * @param string $nodeId 迷你搜索ID
  * @return array
  */
 public function report($signature, $nodeId)
 {
     //编制索引成功
     $buildSuccess = PluginMiniSearchFile::getInstance()->buildSuccess($signature, $nodeId);
     if ($buildSuccess) {
         //为迷你搜索节点服务器增加索引数
         PluginMiniSearchNode::getInstance()->newBuildFile($nodeId);
         //删除索引任务
         PluginMiniSearchBuildTask::getInstance()->delete($signature, $nodeId);
     }
     return array("success" => true);
 }
Esempio n. 3
0
 /**
  *根据文件的Hash值下载内容
  *@param string $signature 文件hash值
  *@return array
  *
  */
 function pullText($signature)
 {
     $version = PluginMiniDocVersion::getInstance()->getBySignature($signature);
     if (isset($version)) {
         $mimeTypeList = array("text/plain", "text/html", "application/javascript", "text/css", "application/xml");
         foreach ($mimeTypeList as $mimeType) {
             if ($mimeType === $version["mime_type"]) {
                 PluginMiniSearchFile::getInstance()->create($signature);
                 return;
             }
         }
         $mimeTypeList = array("application/mspowerpoint", "application/msword", "application/msexcel", "application/pdf");
         foreach ($mimeTypeList as $mimeType) {
             if ($mimeType === $version["mime_type"]) {
                 //文档类增量转换
                 //doc/ppt/xls/pdf全文检索需要通过迷你文档拉取文本内容
                 PluginMiniSearchFile::getInstance()->create($signature);
             }
         }
     }
 }
Esempio n. 4
0
 /**
  *
  * 场景1:针对1.5升级到1.7的场景
  * 把系统中的文本文件,提交到文件索引节点,每次做多提交80个转换任务
  * 使用方式:手动执行
  */
 public function actionBuildOldFile()
 {
     $versions = PluginMiniSearchVersion::getInstance()->getTxtBuildList();
     if (empty($versions)) {
         echo "没有需要索引的文本文档了";
     } else {
         foreach ($versions as $version) {
             $signature = $version["file_signature"];
             PluginMiniSearchFile::getInstance()->create($signature);
         }
         echo "本次索引的文本文件有:" . count($versions) . "个\n";
     }
     $versions = PluginMiniSearchVersion::getInstance()->getDocBuildList();
     if (empty($versions)) {
         echo "没有需要索引的文档了";
     } else {
         foreach ($versions as $version) {
             $signature = $version["file_signature"];
             PluginMiniSearchFile::getInstance()->create($signature);
         }
         echo "本次索引的文档有:" . count($versions) . "个\n";
     }
 }