Documentation
¶
Index ¶
- type Engine
- func (engine *Engine) FlushIndex()
- func (engine *Engine) IndexDocument(docID uint64, data types.DocumentIndexData, forceUpdate bool)
- func (engine *Engine) Init(options types.EngineInitOptions)
- func (engine *Engine) MemoryUsage()
- func (engine *Engine) NumDocumentsIndexed() uint64
- func (engine *Engine) NumDocumentsRemoved() uint64
- func (engine *Engine) NumTokenIndexAdded() uint64
- func (engine *Engine) RemoveDocument(docID uint64, forceUpdate bool)
- func (engine *Engine) Search(request types.SearchRequest) (output types.SearchResponse)
- func (engine *Engine) Segment(text string, withSynonyms bool) (tokens []string)
- func (engine *Engine) Shutdown()
- type StopTokens
- type Synonym
- type SynonymGroup
- type Synonyms
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine struct
func (*Engine) IndexDocument ¶
func (engine *Engine) IndexDocument(docID uint64, data types.DocumentIndexData, forceUpdate bool)
IndexDocument 将文档加入索引
输入参数:
docID 标识文档编号,必须唯一,docID == 0 表示非法文档(用于强制刷新索引),[1, +oo) 表示合法文档 data 见DocumentIndexData注释 forceUpdate 是否强制刷新 cache,如果设为 true,则尽快添加到索引,否则等待 cache 满之后一次全量添加
注意:
- 这个函数是线程安全的,请尽可能并发调用以提高索引速度
- 这个函数调用是非同步的,也就是说在函数返回时有可能文档还没有加入索引中,因此 如果立刻调用Search可能无法查询到这个文档。强制刷新索引请调用FlushIndex函数。
func (*Engine) Init ¶
func (engine *Engine) Init(options types.EngineInitOptions)
Init 初始化搜索引擎,拉起所有worker
func (*Engine) NumDocumentsIndexed ¶
NumDocumentsIndexed 已加入检索队列的文档数(只用于同步的计数器)
func (*Engine) NumDocumentsRemoved ¶
NumDocumentsRemoved 已加入删除队列的文档数(只用于同步的计数器)
func (*Engine) NumTokenIndexAdded ¶
NumTokenIndexAdded 已加入检索队列的关键词数(只用于同步的计数器)
func (*Engine) RemoveDocument ¶
RemoveDocument 将文档从索引中删除
输入参数:
docID 标识文档编号,必须唯一,docID == 0 表示非法文档(用于强制刷新索引),[1, +oo) 表示合法文档 forceUpdate 是否强制刷新 cache,如果设为 true,则尽快删除索引,否则等待 cache 满之后一次全量删除
注意:
- 这个函数是线程安全的,请尽可能并发调用以提高索引速度
- 这个函数调用是非同步的,也就是说在函数返回时有可能文档还没有加入索引中,因此 如果立刻调用Search可能无法查询到这个文档。强制刷新索引请调用FlushIndex函数。
func (*Engine) Search ¶
func (engine *Engine) Search(request types.SearchRequest) (output types.SearchResponse)
Search 查找满足搜索条件的文档,此函数线程安全
type StopTokens ¶
type StopTokens struct {
// contains filtered or unexported fields
}
StopTokens struct
func (*StopTokens) Init ¶
func (st *StopTokens) Init(stopTokenFile string)
Init 加载停止词库 从stopTokenFile中读入停用词,一个词一行 文档索引建立时会跳过这些停用词
func (*StopTokens) IsStopToken ¶
func (st *StopTokens) IsStopToken(token string) bool
IsStopToken 是否停止词
type SynonymGroup ¶
type SynonymGroup []*Synonym
SynonymGroup 同义词组,组内单词平权,分词时会自动添加同义词到token中,逻辑搜索时会添加“or”逻辑
Click to show internal directories.
Click to hide internal directories.