Go Open Source, Distributed, Simple and efficient full text search engine.
采用对商业应用友好的Apache License v2发布
Riot v0.10.0 was released in Nov 2017, check the Changelog for the full details.
QQ 群: 120563750
go get -u github.com/go-ego/riot
需要 Go 版本至少 1.8
Riot 使用 dep 管理 vendor 依赖, but we don't commit the vendored packages themselves to the Riot git repository. Therefore, a simple go get is not supported because the command is not vendor aware.
请用 dep 管理它, 运行 dep ensure
克隆依赖.
go get -u github.com/go-ego/re
创建 riot 项目
$ re riot my-riotapp
运行我们创建的 riot 项目, 你可以导航到应用程序文件夹并执行:
$ cd my-riotapp && re run
先看一个例子(来自 simplest_example.go)
package main
import (
"log"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)
var (
// searcher 是协程安全的
searcher = riot.Engine{}
)
func main() {
// 初始化
searcher.Init(types.EngineOpts{
Using: 3,
GseDict: "zh",
// GseDict: "your gopath"+"/src/github.com/go-ego/riot/data/dict/dictionary.txt",
})
defer searcher.Close()
text := "此次百度收购将成中国互联网最大并购"
text1 := "百度宣布拟全资收购91无线业务"
text2 := "百度是中国最大的搜索引擎"
// 将文档加入索引,docId 从1开始
searcher.Index(1, types.DocData{Content: text})
searcher.Index(2, types.DocData{Content: text1}, false)
searcher.Index(3, types.DocData{Content: text2}, true)
// 等待索引刷新完毕
searcher.Flush()
// engine.FlushIndex()
// 搜索输出格式见 types.SearchResp 结构体
log.Print(searcher.Search(types.SearchReq{Text:"百度中国"}))
}
是不是很简单!
然后看看一个入门教程,教你用不到200行 Go 代码实现一个微博搜索网站。
package main
import (
"log"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)
var (
searcher = riot.New("zh")
)
func main() {
data := types.DocData{Content: `I wonder how, I wonder why
, I wonder where they are`}
data1 := types.DocData{Content: "所以, 你好, 再见"}
data2 := types.DocData{Content: "没有理由"}
searcher.Index(1, data)
searcher.Index(2, data1)
searcher.IndexDoc(3, data2)
searcher.Flush()
req := types.SearchReq{Text: "你好"}
search := searcher.Search(req)
log.Println("search...", search)
}
支持 riot, buy me a coffee.
Donate money by paypal to my account vzvway@gmail.com
Riot is primarily distributed under the terms of the Apache License (Version 2.0), base on wukong.