Go Open Source, Distributed, Simple and efficient Search Engine; Warning: This is V1 and beta version, because of big memory consume, and the V2 will be rewrite all code.
- my OS info:
LSB Version: n/a
Distributor ID: ManjaroLinux
Description: Manjaro Linux
Release: 18.0.4
- go version go1.12.4 linux/amd64my operate step:
1.execute cmd : go run test.go ,index can add and search
2.change code only search
3.Ctrl+c and execute cmd : go run test.go ,no data find
my console log2019/07/05 17:20:37 Dictionary file path is empty, load the default dictionary file. 2019/07/05 17:20:37 Load the gse dictionary: "/home/zlykernel/go/src/github.com/go-ego/gse/data/dict/dictionary.txt" 2019/07/05 17:20:40 Gse dictionary loaded finished. 2019/07/05 17:20:42 创建的索引数量: 0 2019/07/05 17:20:42 建索引开始 2019/07/05 17:20:42 添加了文件标题为: title1 2019/07/05 17:20:42 创建的索引数量: 1 2019/07/05 17:20:42 after Add 创建的索引数量: 1 2019/07/05 17:20:42 建索引完毕 ,创建的索引数量 = 1 2019/07/05 17:20:42 查询: {{[content1] false 1} [{{2019-07-05 17:20:42 [0] [] []} content1 {title1 author1 2019-07-05 17:20:42 0} <nil>}]} zlykernel@zlykernel-pc ~/go/src/livecode-riotapp/middleware/riot_server/test go run test.go 2019/07/05 17:20:57 Dictionary file path is empty, load the default dictionary file. 2019/07/05 17:20:57 Load the gse dictionary: "/home/zlykernel/go/src/github.com/go-ego/gse/data/dict/dictionary.txt" 2019/07/05 17:20:59 Gse dictionary loaded finished. 2019/07/05 17:21:01 创建的索引数量: 0 2019/07/05 17:21:01 查询: {{[content1] false 0} []}- my code:
package main
this problem has already solved!
add gob.Register(types.Attri{}) before init engine
like this:
import "github.com/go-ego/riot/types" func init() { gob.Register(types.Attri{}) rpc.InitEngine(config) }
- my OS info: LSB Version: n/a Distributor ID: ManjaroLinux Description: Manjaro Linux Release: 18.0.4 - go version go1.12.4 linux/amd64 my operate step:
1.execute cmd :
go run test.go
,index can add and search 2.change code only search 3.Ctrl+c and execute cmd :go run test.go
,no data findmy console log
2019/07/05 17:20:37 Dictionary file path is empty, load the default dictionary file. 2019/07/05 17:20:37 Load the gse dictionary: "/home/zlykernel/go/src/github.com/go-ego/gse/data/dict/dictionary.txt" 2019/07/05 17:20:40 Gse dictionary loaded finished. 2019/07/05 17:20:42 创建的索引数量: 0 2019/07/05 17:20:42 建索引开始 2019/07/05 17:20:42 添加了文件标题为: title1 2019/07/05 17:20:42 创建的索引数量: 1 2019/07/05 17:20:42 after Add 创建的索引数量: 1 2019/07/05 17:20:42 建索引完毕 ,创建的索引数量 = 1 2019/07/05 17:20:42 查询: {{[content1] false 1} [{{2019-07-05 17:20:42 [0] [] []} content1 {title1 author1 2019-07-05 17:20:42 0} <nil>}]} zlykernel@zlykernel-pc ~/go/src/livecode-riotapp/middleware/riot_server/test go run test.go 2019/07/05 17:20:57 Dictionary file path is empty, load the default dictionary file. 2019/07/05 17:20:57 Load the gse dictionary: "/home/zlykernel/go/src/github.com/go-ego/gse/data/dict/dictionary.txt" 2019/07/05 17:20:59 Gse dictionary loaded finished. 2019/07/05 17:21:01 创建的索引数量: 0 2019/07/05 17:21:01 查询: {{[content1] false 0} []}
- my code: package mainimport ( "log" "net/http" "time" "os" "os/signal" // rhttp "github.com/go-ego/riot/net/http"
)
var ( // searcher is coroutine safe searcher = riot.Engine{}
)
//标题、作者、标签 func AddContent(title,content,author string,labels[]string)(err error) { //defer searcher.Close() //错误 log.Println("添加了文件标题为: ", title)
}
func Add(w http.ResponseWriter, req *http.Request){ AddContent("title1","content1","author1",[]string{"false"}) log.Println("after Add 创建的索引数量: ", searcher.NumDocsIndexed()) // restoreIndex() }
func restoreIndex() { searcher.Init(opts) defer searcher.Close() searcher.Flush() log.Println("recover index number: ", searcher.NumDocsIndexed()) }
func main() { searcher.Init(opts) // restoreIndex() log.Println("创建的索引数量: ", searcher.NumDocsIndexed()) // http.HandleFunc("/search", rhttp.Search) // http.HandleFunc("/dist", rhttp.WgDist) // http.HandleFunc("/Add", Add) // log.Println("listen and serve on 8080...") // log.Fatal(http.ListenAndServe(":8088", nil))
}
`