From 465362d9a79ed7f690b3e8c8da2ff2dd8d821808 Mon Sep 17 00:00:00 2001 From: phachon Date: Wed, 16 Sep 2020 14:22:09 +0800 Subject: [PATCH 1/2] del fulltext search --- app/bootstrap.go | 4 +-- app/controllers/main.go | 42 ++++++++++++------------ app/modules/system/controllers/config.go | 2 +- app/services/doc_index.go | 8 ++--- views/main/search.html | 4 +-- views/system/config/form.html | 36 ++++++++++---------- 6 files changed, 48 insertions(+), 48 deletions(-) diff --git a/app/bootstrap.go b/app/bootstrap.go index 151cef82..ce3bb748 100644 --- a/app/bootstrap.go +++ b/app/bootstrap.go @@ -54,8 +54,8 @@ func init() { initDB() checkUpgrade() initDocumentDir() - initSearch() - initWork() + //initSearch() + //initWork() StartTime = time.Now().Unix() } diff --git a/app/controllers/main.go b/app/controllers/main.go index 8eccff49..2f6689b8 100644 --- a/app/controllers/main.go +++ b/app/controllers/main.go @@ -1,10 +1,7 @@ package controllers import ( - "github.com/go-ego/riot/types" "github.com/phachon/mm-wiki/app/models" - "github.com/phachon/mm-wiki/app/utils" - "github.com/phachon/mm-wiki/global" "strings" ) @@ -164,24 +161,27 @@ func (this *MainController) Search() { } searchDocContents := make(map[string]string) // 默认根据内容搜索 - if searchType == "title" { - documents, err = models.DocumentModel.GetDocumentsByLikeName(keyword) - } else { - searchRes := global.DocSearcher.SearchDoc(types.SearchReq{Text: keyword}) - searchDocIds := []string{} - for _, searchDoc := range searchRes.Docs { - if len(searchDoc.TokenSnippetLocs) == 0 { - continue - } - docId := searchDoc.DocId - content := searchDoc.Content - locIndex := searchDoc.TokenSnippetLocs[0] - searchContent := utils.Misc.SubStrUnicodeBySubStrIndex(content, keyword, locIndex, 30, 30) - searchDocContents[docId] = searchContent - searchDocIds = append(searchDocIds, docId) - } - documents, err = models.DocumentModel.GetDocumentsByDocumentIds(searchDocIds) - } + // v0.2.1 下线全文搜索功能 + searchType = "title" + //if searchType == "title" { + // documents, err = models.DocumentModel.GetDocumentsByLikeName(keyword) + //} else { + // searchRes := global.DocSearcher.SearchDoc(types.SearchReq{Text: keyword}) + // searchDocIds := []string{} + // for _, searchDoc := range searchRes.Docs { + // if len(searchDoc.TokenSnippetLocs) == 0 { + // continue + // } + // docId := searchDoc.DocId + // content := searchDoc.Content + // locIndex := searchDoc.TokenSnippetLocs[0] + // searchContent := utils.Misc.SubStrUnicodeBySubStrIndex(content, keyword, locIndex, 30, 30) + // searchDocContents[docId] = searchContent + // searchDocIds = append(searchDocIds, docId) + // } + // documents, err = models.DocumentModel.GetDocumentsByDocumentIds(searchDocIds) + //} + documents, err = models.DocumentModel.GetDocumentsByLikeName(keyword) if err != nil { this.ErrorLog("搜索文档出错:" + err.Error()) this.ViewError("搜索文档错误!") diff --git a/app/modules/system/controllers/config.go b/app/modules/system/controllers/config.go index 9434aab1..84dd272f 100644 --- a/app/modules/system/controllers/config.go +++ b/app/modules/system/controllers/config.go @@ -114,7 +114,7 @@ func (this *ConfigController) Modify() { } // 更新后的回调 - this.configUpdateCallback(updateKeys) + //this.configUpdateCallback(updateKeys) this.InfoLog("修改全局配置成功") this.jsonSuccess("修改全局配置成功", nil, "/system/config/global") } diff --git a/app/services/doc_index.go b/app/services/doc_index.go index 61d85f4b..5386f202 100644 --- a/app/services/doc_index.go +++ b/app/services/doc_index.go @@ -20,10 +20,10 @@ func NewDocIndexService() *DocIndex { } func (di *DocIndex) IsUpdateDocIndex() bool { - fulltextSearchOpen := models.ConfigModel.GetConfigValueByKey(models.ConfigKeyFulltextSearch, "0") - if fulltextSearchOpen == "1" { - return true - } + //fulltextSearchOpen := models.ConfigModel.GetConfigValueByKey(models.ConfigKeyFulltextSearch, "0") + //if fulltextSearchOpen == "1" { + // return true + //} return false } diff --git a/views/main/search.html b/views/main/search.html index dd2604b4..be9ecb71 100644 --- a/views/main/search.html +++ b/views/main/search.html @@ -8,7 +8,7 @@ 搜索方式 @@ -25,7 +25,7 @@
{{if eq .count 0}} {{else}}
diff --git a/views/system/config/form.html b/views/system/config/form.html index abff8ebe..63465cea 100644 --- a/views/system/config/form.html +++ b/views/system/config/form.html @@ -55,24 +55,24 @@ * 开启统一登录必须先添加并启用登录认证
-
- -
- -
-
- * 开启全文搜索后,搜索时可根据文档内容搜索 -
-
-
- -
- -
-
- * 开启全文搜索后,定时更新全文索引的时间间隔,单位秒(默认 1h,全文索引不需要频繁更新,文档更新后自动更新文档索引) -
-
+{{/*
*/}} +{{/* */}} +{{/*
*/}} +{{/* */}} +{{/*
*/}} +{{/*
*/}} +{{/* * 开启全文搜索后,搜索时可根据文档内容搜索*/}} +{{/*
*/}} +{{/*
*/}} +{{/*
*/}} +{{/* */}} +{{/*
*/}} +{{/* */}} +{{/*
*/}} +{{/*
*/}} +{{/* * 开启全文搜索后,定时更新全文索引的时间间隔,单位秒(默认 1h,全文索引不需要频繁更新,文档更新后自动更新文档索引)*/}} +{{/*
*/}} +{{/*
*/}}
From 0b222439926f4ce8a96293847294f136bc5a5e3f Mon Sep 17 00:00:00 2001 From: phachon Date: Wed, 16 Sep 2020 14:23:40 +0800 Subject: [PATCH 2/2] del fulltext search --- CHANGELOG.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af3fa82f..b5c18946 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # 更新日志: +## v0.2.1(2020-09) + +### Fix Bug & Add Feature +#### 修复bug +1. 暂时去掉全文搜索功能 + +#### 新增功能 +无 + +### 升级(Upgrade) +1. 下载新版本到部署该项目的根目录 +2. 覆盖解压 (tar -zxvf mm-wiki-v0.2.0-linux-amd64.tar.gz) +3. 执行升级命令 +``` +./mm-wiki --conf conf/mm-wiki.conf --upgrade +``` +4. 重新启动 +``` +./mm-wiki --conf conf/mm-wiki.conf +``` + ## v0.2.0(2020-06) ### Fix Bug & Add Feature