-
Notifications
You must be signed in to change notification settings - Fork 475
The persistent storage data restart project disappears #74
Comments
刚添加完的索引是能够查询到的,但是重启工程之后,就查询不到之前添加的索引了 |
Please provide the code. |
//标题、作者、标签
func AddContent(title,content,author string,labels[]string)(err error) {
//defer searcher.Close()
//错误
log.Println("添加了文件标题为: ", title)
//err = GetError()
//为文件添加属性
attri :=types.Attri{title,author,unit.GetTimeNow(),0}
ct :=types.DocData{Content: content}
ct.Attri=attri
//如果类别不为空则添加类别
if labels != nil || len(labels) >0{
ct.Labels = labels
}
//生成主键
docid := uint64(time.Now().Unix())
//插入
searcher.Index(docid, ct)
//searcher.Index(22, types.DocData{Content: content})
//刷新
searcher.Flush()
log.Println("创建的索引数量: ", searcher.NumDocsIndexed())
return err
} |
我是使用了一个web框架(beego),请求过来之后在进行添加搜索文档的 |
Take a look at the code I duplicated.Adding is good, but as long as the service is restarted, there is no data added before. |
I used a web framework (beego) |
Please restore index first, then try gob registration, gob.Register(MyAttriStruct{}) |
Thank you very much. The problem has been solved. |
|
我也遇到同样问题,go version go1.12.4 linux/amd64 import (
) var (
) //标题、作者、标签
} func Add(w http.ResponseWriter, req *http.Request){ func restoreIndex() { func main() {
} |
The persistent storage data restart project disappears
The text was updated successfully, but these errors were encountered: