Esempio n. 1
0
 /**
  * 取得keyword的unicode码
  * 
  * @param  string $keyword
  * @return string        
  */
 public function prepareKeyword($keyword)
 {
     $spliter = new Spliter();
     $keywords = explode(' ', $keyword);
     $against = '';
     foreach ($keywords as $kw) {
         $splitedWords = $spliter->utf8Split($kw);
         $against .= $splitedWords['words'];
     }
     return $against;
 }
Esempio n. 2
0
 /**
  * 更新查询索引表
  * 
  * @param  object $object
  * @param  array $data
  * @param boolean $isEdit false的时候为增加,true的时候为edit
  * @return boolean
  */
 private function saveSeachFullText($object, \App\Services\Admin\Content\Param\ContentSave $data, $isEdit = false)
 {
     $spliterObject = new Spliter();
     $titleSplited = $spliterObject->utf8Split($data['title']);
     $index['title'] = $titleSplited['words'];
     $contentSplited = $spliterObject->utf8Split(strip_tags($data['content']));
     $index['content'] = $contentSplited['words'];
     $summarySplited = $spliterObject->utf8Split(strip_tags($data['summary']));
     $index['summary'] = $summarySplited['words'];
     $index['article_id'] = $checkIndex['article_id'] = $object->contentAutoId;
     if ($isEdit === false) {
         $index['added_date'] = $index['edited_date'] = time();
     }
     if ($isEdit === true) {
         $index['edited_date'] = time();
     }
     $indexModel = new SearchIndexModel();
     $result = $indexModel->saveIndex($checkIndex, $index);
     if ($result === false) {
         throw new Exception("save article dict index error.");
     }
 }