engine

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2015 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NumNanosecondsInAMillisecond = 1000000
	PersistentStorageFilePrefix  = "wukong"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Count

type Count struct {
	Num int
	sync.Mutex
}

type Engine

type Engine struct {

	// 动态添加工作协程的锁
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Engine) Close

func (engine *Engine) Close()

关闭引擎

func (*Engine) FlushIndex

func (engine *Engine) FlushIndex()

阻塞等待直到所有索引添加完毕

func (*Engine) IndexDocument

func (engine *Engine) IndexDocument(docId string, data types.DocumentIndexData, shard uint64, documentIndexChan ...chan *types.DocumentIndex)

将文档加入索引

输入参数:

docId	标识文档编号,必须唯一
data	见DocumentIndexData注释

注意:

  1. 这个函数是线程安全的,请尽可能并发调用以提高索引速度。
  2. 这个函数调用是非同步的,也就是说在函数返回时有可能文档还没有加入索引中,因此 如果立刻调用Search可能无法查询到这个文档。强制刷新索引请调用FlushIndex函数。
  3. 可选参数documentIndexChan不为空时,将在分词步骤写入关键词及其词频信息,此时程序并进入等待状态, 只有当其通道内所有数据被外部读出来,程序才能继续运行、建立索引。 这样设计的目的在于让外部程序可以在索引建立之前,处理一些与documentIndexChan相关的事务。 注意:documentIndexChan必须为异步通道,其容量设置为欲传入IndexDocument方法的总次数!

func (*Engine) Init

func (engine *Engine) Init(options types.EngineInitOptions)

func (*Engine) NumDocumentsIndexed

func (engine *Engine) NumDocumentsIndexed() uint64

func (*Engine) NumTokenIndexAdded

func (engine *Engine) NumTokenIndexAdded() uint64

func (*Engine) RemoveDocument

func (engine *Engine) RemoveDocument(docId string, shards ...uint64)

将文档从索引中删除

输入参数:

	docId	标识文档编号,必须唯一
 shards  指定分片,为空时在所有分片下操作

注意:这个函数仅从排序器中删除文档,索引器不会发生变化。

func (*Engine) Search

func (engine *Engine) Search(request types.SearchRequest) (output types.SearchResponse)

查找满足搜索条件的文档,此函数线程安全

func (*Engine) Segment

func (engine *Engine) Segment(content string) (keywords []string)

只分词与过滤弃用词

type StopTokens

type StopTokens struct {
	// contains filtered or unexported fields
}

func (*StopTokens) Init

func (st *StopTokens) Init(stopTokenFile string)

从stopTokenFile中读入停用词,一个词一行 文档索引建立时会跳过这些停用词

func (*StopTokens) IsStopToken

func (st *StopTokens) IsStopToken(token string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL