|
1 | 1 | package controllers |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "github.com/go-ego/riot/types" |
5 | 4 | "github.com/phachon/mm-wiki/app/models" |
6 | | - "github.com/phachon/mm-wiki/app/utils" |
7 | | - "github.com/phachon/mm-wiki/global" |
8 | 5 | "strings" |
9 | 6 | ) |
10 | 7 |
|
@@ -164,24 +161,27 @@ func (this *MainController) Search() { |
164 | 161 | } |
165 | 162 | searchDocContents := make(map[string]string) |
166 | 163 | // 默认根据内容搜索 |
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) |
185 | 185 | if err != nil { |
186 | 186 | this.ErrorLog("搜索文档出错:" + err.Error()) |
187 | 187 | this.ViewError("搜索文档错误!") |
|
0 commit comments