import "github.com/go-ego/riot"
Package riot is riot engine
Package riot full text search engine
counters.go engine.go indexer_worker.go info.go ranker_worker.go riot.go riot_pkg.go segment.go stop_tokens.go store_worker.go test_utils.go
const ( // Version get the riot version Version string = "v0.10.0.425, Danube River!" // NumNanosecondsInAMillisecond nano-seconds in a milli-second num NumNanosecondsInAMillisecond = 1000000 // StoreFilePrefix persistent store file prefix StoreFilePrefix = "riot" // DefaultPath default db path DefaultPath = "./riot-index" )
var ( // InitMemUsed init mem used InitMemUsed uint64 // InitDiskUsed init disk used InitDiskUsed uint64 )
var (
TestIndexOpts = rankEngineOpts(rankOptsMax10)
)
CPUInfo returns the cpu info
CPUPercent returns the amount of use cpu in percent.
DiskFree returns the amount of free disk in bytes.
DiskPercent returns the amount of use disk in percent.
DiskTotal returns the amount of total disk in bytes.
DiskUsed returns the amount of use disk in bytes.
GetVersion get the riot version
KernelVer returns the kernel version as a string.
MemFree returns the amount of free memory in bytes.
MemPercent returns the amount of use memory in percent.
MemTotal returns the amount of total memory in bytes.
MemUsed returns the amount of used memory in bytes.
func OrderlessOpts(idOnly bool) types.EngineOpts
Platform returns the platform name and OS Version.
PlatformInfo fetches system platform information.
ToGB bytes to gb
ToKB bytes to kb
ToMB bytes to mb
func Try(fun func(), handler func(interface{}))
Try handler(err)
Uptime returns the system uptime in seconds.
type Engine struct {
// contains filtered or unexported fields
}
Engine initialize the engine
New create a new engine with mode
NewEngine create a new engine
CheckMem check the memory when the memory is larger than 99.99% using the store
Close close the engine 关闭引擎
Flush block wait until all indexes are added 阻塞等待直到所有索引添加完毕
FlushIndex block wait until all indexes are added 阻塞等待直到所有索引添加完毕
ForSplitData for split segment's data, segspl
GetAllDocIds get all the DocId from the storage database and return 从数据库遍历所有的 DocId, 并返回
GetDBAllDocs get the db all docs
GetDBAllIds get all the DocId from the storage database and return 从数据库遍历所有的 DocId, 并返回
HasDoc if the document is exist return true
HasDocDB if the document is exist in the database return true
Index add the document to the index
IndexDoc add the document to the index 将文档加入索引
输入参数:
docId 标识文档编号,必须唯一,docId == 0 表示非法文档(用于强制刷新索引),[1, +oo) 表示合法文档 data 见 DocIndexData 注释 forceUpdate 是否强制刷新 cache,如果设为 true,则尽快添加到索引,否则等待 cache 满之后一次全量添加
注意:
1. 这个函数是线程安全的,请尽可能并发调用以提高索引速度 2. 这个函数调用是非同步的,也就是说在函数返回时有可能文档还没有加入索引中,因此 如果立刻调用Search可能无法查询到这个文档。强制刷新索引请调用FlushIndex函数。
func (engine *Engine) Indexer(options types.EngineOpts)
Indexer initialize the indexer channel
func (engine *Engine) Init(options types.EngineOpts)
Init initialize the engine
InitStore initialize the persistent store channel
func (engine *Engine) NotTimeOut(request types.SearchReq, rankerReturnChan chan rankerReturnReq) ( rankOutArr interface{}, numDocs int)
NotTimeOut not set engine timeout
NumDocsIndexed documents indexed number, deprecated
NumDocsRemoved documents removed number, deprecated
NumIndexed documents indexed number
NumRemoved documents removed number
NumTokenAdded added token index number
NumTokenIndexAdded added token index number, deprecated
PinYin get the Chinese alphabet and abbreviation
func (engine *Engine) RankID(request types.SearchReq, rankOpts types.RankOpts, tokens []string, rankerReturnChan chan rankerReturnReq) (output types.SearchResp)
RankID rank docs by types.ScoredIDs
func (engine *Engine) Ranker(options types.EngineOpts)
Ranker initialize the ranker channel
func (engine *Engine) Ranks(request types.SearchReq, rankOpts types.RankOpts, tokens []string, rankerReturnChan chan rankerReturnReq) (output types.SearchResp)
Ranks rank docs by types.ScoredDocs
RemoveDoc remove the document from the index 将文档从索引中删除
输入参数:
docId 标识文档编号,必须唯一,docId == 0 表示非法文档(用于强制刷新索引),[1, +oo) 表示合法文档 forceUpdate 是否强制刷新 cache,如果设为 true,则尽快删除索引,否则等待 cache 满之后一次全量删除
注意:
1. 这个函数是线程安全的,请尽可能并发调用以提高索引速度 2. 这个函数调用是非同步的,也就是说在函数返回时有可能文档还没有加入索引中,因此 如果立刻调用 Search 可能无法查询到这个文档。强制刷新索引请调用 FlushIndex 函数。
Search find the document that satisfies the search criteria. This function is thread safe 查找满足搜索条件的文档,此函数线程安全
SearchDoc find the document that satisfies the search criteria. This function is thread safe, return not IDonly
SearchID find the document that satisfies the search criteria. This function is thread safe, return IDonly
Segment get the word segmentation result of the text 获取文本的分词结果, 只分词与过滤弃用词
Store start the persistent store work connection
func (engine *Engine) TimeOut(request types.SearchReq, rankerReturnChan chan rankerReturnReq) ( rankOutArr interface{}, numDocs int, isTimeout bool)
TimeOut set engine timeout
Tokens get the engine tokens
UsedDisk returns the amount of use disk in bytes after init() func.
UsedMem returns the amount of riot used memory in bytes after init() func.
WithGse Using user defined segmenter If using a not nil segmenter and the dictionary is loaded, the `opt.GseDict` will be ignore.
type RankByTokenProximity struct { }
func (rule RankByTokenProximity) Score( doc types.IndexedDoc, fields interface{}) []float32
type StopTokens struct {
// contains filtered or unexported fields
}
StopTokens stop tokens map
func (st *StopTokens) Init(stopTokenFile string)
Init 从 stopTokenFile 中读入停用词,一个词一行 文档索引建立时会跳过这些停用词
func (st *StopTokens) IsStopToken(token string) bool
IsStopToken to determine whether to stop token
TMap defines the tokens map type map[string][]int
Path | Synopsis |
---|---|
core | Package core is riot core |
data | |
data/client | |
data/riot | |
data/riot1 | |
data/riot1/heartb | |
data/riot/heartb | |
engine | Package engine is riot engine |
examples/benchmark | riot 性能测试 |
examples/codelab | 一个微博搜索的例子。 |
examples/dict | |
examples/dict2 | |
examples/info | |
examples/logic | |
examples/new | |
examples/pinyin | |
examples/pinyin/old | |
examples/pinyin_weibo | 一个微博 pinyin 搜索的例子。 |
examples/simple | |
examples/simple/zh | |
examples/store | |
examples/weibo | |
geo | |
net | Package net is riot net |
net/com | |
net/grpc | |
net/grpc/riot-pb | |
net/heartb | |
net/http | |
net/rpcx | |
store | |
store/batch | |
types | Package types is riot types |
utils |
Package riot imports 24 packages (graph) and is imported by 33 packages. Updated 2020-10-19. Refresh now. Tools for package owners.