new: Improve the automatic update module, add authentication, and fix some bugs

This commit is contained in:
2024-12-18 00:02:55 +08:00
parent 95f4496ab6
commit 05df3fa376
12 changed files with 109 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
package mApp
import (
"fmt"
"io"
"os"
@@ -9,13 +10,15 @@ import (
)
func (ma *MApp) loadPostIndex() {
cachePath := fmt.Sprintf("%s/persistent", ma.Config.CachePath)
ma.searcher = nil
ma.searcher = &engine.Engine{}
ma.searcher.Init(types.EngineInitOptions{
UsePersistentStorage: true,
PersistentStorageFolder: "tmp",
StopTokenFile: "data/stop_tokens.txt",
SegmenterDictionaries: "data/dictionary.txt",
PersistentStorageFolder: cachePath,
StopTokenFile: "data/search/stop_tokens.txt",
SegmenterDictionaries: "data/search/dictionary.txt",
IndexerInitOptions: &types.IndexerInitOptions{
IndexType: types.LocationsIndex,
},
@@ -26,6 +29,7 @@ func (ma *MApp) loadPostIndex() {
postData, _ := io.ReadAll(postFile)
ma.searcher.IndexDocument(post.Index, types.DocumentIndexData{Content: string(postData)}, false)
_ = postFile.Close()
}
ma.searcher.FlushIndex()