Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DocIterator ¶
type DocIterator interface {
// 获取下个待索引的doc,返回nil表示迭代结束.
NextDoc() interface{}
}
type Goose ¶
type Goose struct {
// contains filtered or unexported fields
}
goose的入口程序.
func (*Goose) SetIndexStrategy ¶
func (this *Goose) SetIndexStrategy(sty IndexStrategy)
func (*Goose) SetSearchStrategy ¶
func (this *Goose) SetSearchStrategy(sty SearchStrategy)
type GooseBuild ¶
type GooseBuild struct {
// contains filtered or unexported fields
}
Goose的静态库生成程序.
func NewGooseBuild ¶
func NewGooseBuild() *GooseBuild
func (*GooseBuild) Init ¶
func (this *GooseBuild) Init(confPath string, indexSty IndexStrategy, toIndexFile string) (err error)
根据配置文件进行初始化. 需要外部指定索引策略,策略可以重新设计. 需要外部知道被索引文件(这个易变信息不适合放配置)
func (*GooseBuild) Run ¶
func (this *GooseBuild) Run() (err error)
type GooseSearch ¶
type GooseSearch struct {
// contains filtered or unexported fields
}
Goose检索程序.核心工作是提供检索服务,同时支持动态插入索引.
func NewGooseSearch ¶
func NewGooseSearch() *GooseSearch
func (*GooseSearch) Init ¶
func (this *GooseSearch) Init(confPath string, indexSty IndexStrategy, searchSty SearchStrategy) (err error)
func (*GooseSearch) Run ¶
func (this *GooseSearch) Run() error
type IndexStrategy ¶
type IndexStrategy interface { // 全局初始化的接口 Init(conf config.Conf) error // 分析一个doc,返回其中的term列表,Value,Data ParseDoc(doc interface{}, context *StyContext) (OutIdType, []TermInDoc, Value, Data, error) }
建索引策略. 框架会调用一次Init接口进行初始化,建索引的时候会N个goroutine调用ParseDoc
type MergeEngine ¶
type MergeEngine struct {
// contains filtered or unexported fields
}
func NewMergeEngine ¶
func NewMergeEngine(db DataBaseReader, termList []TermInQuery) (*MergeEngine, error)
func (*MergeEngine) Next ¶
func (this *MergeEngine) Next(termInDoclist []TermInDoc) (inId InIdType, currValid, allfinish bool)
type SearchStrategy ¶
type SearchStrategy interface { // 全局初始化的接口 Init(conf config.Conf) error // 解析请求 // 返回term列表,一个由策略决定的任意数据,后续接口都会透传 ParseQuery(request []byte, context *StyContext) ([]TermInQuery, interface{}, error) // 对一个结果进行打分,确定相关性 // queryInfo : ParseQuery策略返回的结构 // inId : 需要打分的doc的内部id // outId : 需求打分的doc的外部id // termInQuery : 所有term在query中的打分 // termInDoc : 所有term在doc中的打分 // termCnt : term数量 // Weight : 返回doc的相关性得分 // 返回错误当前结果则丢弃 // @NOTE query中的term不一定能命中doc,TermInDoc.Weight == 0表示这种情况 CalWeight(queryInfo interface{}, inId InIdType, outId OutIdType, termInQuery []TermInQuery, termInDoc []TermInDoc, termCnt uint32, context *StyContext) (TermWeight, error) // 合并三个最初的接口(Filt,Adjust,Response)为一个 // 划分的几个接口,只是给策略增加不必要的麻烦,修改全部开放给策略自定义实现 Response(queryInfo interface{}, list SearchResultList, valueReader ValueReader, dataReader DataReader, response []byte, context *StyContext) (reslen int, err error) }
type Searcher ¶
type Searcher struct {
// contains filtered or unexported fields
}
func NewSearcher ¶
func NewSearcher(db DataBaseReader, sty SearchStrategy) (*Searcher, error)
type StaticIndexer ¶
type StaticIndexer struct {
// contains filtered or unexported fields
}
静态索引生成类.
func NewStaticIndexer ¶
func NewStaticIndexer(db DataBaseWriter, sty IndexStrategy) (*StaticIndexer, error)
func (*StaticIndexer) BuildIndex ¶
func (this *StaticIndexer) BuildIndex(iter DocIterator) error
并发多个协程分析doc,最终阻塞完成写入db后返回
type StyContext ¶
type StyContext struct { // 供策略打日志使用 Log *log.GooseLogger }
type VarIndexer ¶
type VarIndexer struct {
// contains filtered or unexported fields
}
动态索引生成类.
func NewVarIndexer ¶
func NewVarIndexer(db DataBaseWriter, sty IndexStrategy) (*VarIndexer, error)
func (*VarIndexer) BuildIndex ¶
func (this *VarIndexer) BuildIndex(iter DocIterator) error
单协程完成工作,分析doc然后写入索引结束.
Notes ¶
Bugs ¶
log4go need time to sync ...(wtf) see http://stackoverflow.com/questions/14252766/abnormal-behavior-of-log4go
Source Files ¶
Click to show internal directories.
Click to hide internal directories.