Skip to content

Commit 482083b

Browse files
authored
Merge pull request #249 from phachon/feature/v0.2.1/phachon
del fulltext search
2 parents d429c75 + 0b22243 commit 482083b

File tree

7 files changed

+69
-48
lines changed

7 files changed

+69
-48
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# 更新日志:
22

3+
## v0.2.1(2020-09)
4+
5+
### Fix Bug & Add Feature
6+
#### 修复bug
7+
1. 暂时去掉全文搜索功能
8+
9+
#### 新增功能
10+
11+
12+
### 升级(Upgrade)
13+
1. 下载新版本到部署该项目的根目录
14+
2. 覆盖解压 (tar -zxvf mm-wiki-v0.2.0-linux-amd64.tar.gz)
15+
3. 执行升级命令
16+
```
17+
./mm-wiki --conf conf/mm-wiki.conf --upgrade
18+
```
19+
4. 重新启动
20+
```
21+
./mm-wiki --conf conf/mm-wiki.conf
22+
```
23+
324
## v0.2.0(2020-06)
425

526
### Fix Bug & Add Feature

app/bootstrap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func init() {
5454
initDB()
5555
checkUpgrade()
5656
initDocumentDir()
57-
initSearch()
58-
initWork()
57+
//initSearch()
58+
//initWork()
5959
StartTime = time.Now().Unix()
6060
}
6161

app/controllers/main.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package controllers
22

33
import (
4-
"github.com/go-ego/riot/types"
54
"github.com/phachon/mm-wiki/app/models"
6-
"github.com/phachon/mm-wiki/app/utils"
7-
"github.com/phachon/mm-wiki/global"
85
"strings"
96
)
107

@@ -164,24 +161,27 @@ func (this *MainController) Search() {
164161
}
165162
searchDocContents := make(map[string]string)
166163
// 默认根据内容搜索
167-
if searchType == "title" {
168-
documents, err = models.DocumentModel.GetDocumentsByLikeName(keyword)
169-
} else {
170-
searchRes := global.DocSearcher.SearchDoc(types.SearchReq{Text: keyword})
171-
searchDocIds := []string{}
172-
for _, searchDoc := range searchRes.Docs {
173-
if len(searchDoc.TokenSnippetLocs) == 0 {
174-
continue
175-
}
176-
docId := searchDoc.DocId
177-
content := searchDoc.Content
178-
locIndex := searchDoc.TokenSnippetLocs[0]
179-
searchContent := utils.Misc.SubStrUnicodeBySubStrIndex(content, keyword, locIndex, 30, 30)
180-
searchDocContents[docId] = searchContent
181-
searchDocIds = append(searchDocIds, docId)
182-
}
183-
documents, err = models.DocumentModel.GetDocumentsByDocumentIds(searchDocIds)
184-
}
164+
// v0.2.1 下线全文搜索功能
165+
searchType = "title"
166+
//if searchType == "title" {
167+
// documents, err = models.DocumentModel.GetDocumentsByLikeName(keyword)
168+
//} else {
169+
// searchRes := global.DocSearcher.SearchDoc(types.SearchReq{Text: keyword})
170+
// searchDocIds := []string{}
171+
// for _, searchDoc := range searchRes.Docs {
172+
// if len(searchDoc.TokenSnippetLocs) == 0 {
173+
// continue
174+
// }
175+
// docId := searchDoc.DocId
176+
// content := searchDoc.Content
177+
// locIndex := searchDoc.TokenSnippetLocs[0]
178+
// searchContent := utils.Misc.SubStrUnicodeBySubStrIndex(content, keyword, locIndex, 30, 30)
179+
// searchDocContents[docId] = searchContent
180+
// searchDocIds = append(searchDocIds, docId)
181+
// }
182+
// documents, err = models.DocumentModel.GetDocumentsByDocumentIds(searchDocIds)
183+
//}
184+
documents, err = models.DocumentModel.GetDocumentsByLikeName(keyword)
185185
if err != nil {
186186
this.ErrorLog("搜索文档出错:" + err.Error())
187187
this.ViewError("搜索文档错误!")

app/modules/system/controllers/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (this *ConfigController) Modify() {
114114
}
115115

116116
// 更新后的回调
117-
this.configUpdateCallback(updateKeys)
117+
//this.configUpdateCallback(updateKeys)
118118
this.InfoLog("修改全局配置成功")
119119
this.jsonSuccess("修改全局配置成功", nil, "/system/config/global")
120120
}

app/services/doc_index.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ func NewDocIndexService() *DocIndex {
2020
}
2121

2222
func (di *DocIndex) IsUpdateDocIndex() bool {
23-
fulltextSearchOpen := models.ConfigModel.GetConfigValueByKey(models.ConfigKeyFulltextSearch, "0")
24-
if fulltextSearchOpen == "1" {
25-
return true
26-
}
23+
//fulltextSearchOpen := models.ConfigModel.GetConfigValueByKey(models.ConfigKeyFulltextSearch, "0")
24+
//if fulltextSearchOpen == "1" {
25+
// return true
26+
//}
2727
return false
2828
}
2929

views/main/search.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<span class="input-group-addon"> 搜索方式</span>
99
<select class="form-control" name="search_type">
1010
<option value="title" {{if eq $.search_type "title"}} selected="selected" {{end}}>文档标题</option>
11-
<option value="content" {{if eq $.search_type "content"}} selected="selected" {{end}}>文档内容</option>
11+
{{/* <option value="content" {{if eq $.search_type "content"}} selected="selected" {{end}}>文档内容</option>*/}}
1212
</select>
1313
</div>
1414
</div>
@@ -25,7 +25,7 @@
2525
<hr>
2626
{{if eq .count 0}}
2727
<div class="alert alert-info alert-dismissible fade in" role="alert" style="margin-bottom: 0">
28-
<p><i class="glyphicon glyphicon-volume-up"></i> 抱歉,暂时没有搜索到您想要的结果,切换搜索方式试试看?</p>
28+
<p><i class="glyphicon glyphicon-volume-up"></i> 抱歉,暂时没有搜索到您想要的结果</p>
2929
</div>
3030
{{else}}
3131
<div class="row">

views/system/config/form.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,24 @@
5555
<span class="text-danger"> * 开启统一登录必须先添加并启用登录认证</span>
5656
</div>
5757
</div>
58-
<div class="form-group">
59-
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>开启全文搜索</label>
60-
<div class="col-sm-1">
61-
<input type="checkbox" name="fulltext_search_open" value="1" {{if eq .configValue.fulltext_search_open "1"}} checked="checked" {{end}} placeholder="">
62-
</div>
63-
<div class="col-sm-3 form-comment">
64-
<span class="text-danger"> * 开启全文搜索后,搜索时可根据文档内容搜索</span>
65-
</div>
66-
</div>
67-
<div class="form-group">
68-
<label class="col-sm-2 control-label"><span class="text-danger"> * </span>索引更新间隔</label>
69-
<div class="col-sm-1">
70-
<input type="text" name="doc_search_timer" class="form-control" value="{{.configValue.doc_search_timer}}" placeholder="索引更新间隔(秒)">
71-
</div>
72-
<div class="col-sm-8 form-comment">
73-
<span class="text-danger"> * 开启全文搜索后,定时更新全文索引的时间间隔,单位秒(默认 1h,全文索引不需要频繁更新,文档更新后自动更新文档索引)</span>
74-
</div>
75-
</div>
58+
{{/* <div class="form-group">*/}}
59+
{{/* <label class="col-sm-2 control-label"><span class="text-danger"> * </span>开启全文搜索</label>*/}}
60+
{{/* <div class="col-sm-1">*/}}
61+
{{/* <input type="checkbox" name="fulltext_search_open" value="1" {{if eq .configValue.fulltext_search_open "1"}} checked="checked" {{end}} placeholder="">*/}}
62+
{{/* </div>*/}}
63+
{{/* <div class="col-sm-3 form-comment">*/}}
64+
{{/* <span class="text-danger"> * 开启全文搜索后,搜索时可根据文档内容搜索</span>*/}}
65+
{{/* </div>*/}}
66+
{{/* </div>*/}}
67+
{{/* <div class="form-group">*/}}
68+
{{/* <label class="col-sm-2 control-label"><span class="text-danger"> * </span>索引更新间隔</label>*/}}
69+
{{/* <div class="col-sm-1">*/}}
70+
{{/* <input type="text" name="doc_search_timer" class="form-control" value="{{.configValue.doc_search_timer}}" placeholder="索引更新间隔(秒)">*/}}
71+
{{/* </div>*/}}
72+
{{/* <div class="col-sm-8 form-comment">*/}}
73+
{{/* <span class="text-danger"> * 开启全文搜索后,定时更新全文索引的时间间隔,单位秒(默认 1h,全文索引不需要频繁更新,文档更新后自动更新文档索引)</span>*/}}
74+
{{/* </div>*/}}
75+
{{/* </div>*/}}
7676
<div class="form-group">
7777
<div class="col-sm-offset-2 col-sm-10">
7878
<button type="button" onclick="Form.ajaxSubmit(this.form, false);" class="btn btn-primary">保存</button>

0 commit comments

Comments
 (0)