core

package
v0.0.0-...-360e525 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package core is riot core

Index

Constants

View Source
const RankerDocId = "ranker:doc_id:"
View Source
const TiKvDocIndex = "doc:index:"
View Source
const TiKvDocKeys = "doc:keys:"

Variables

View Source
var (
	// DocInfoGroup 文档信息 [shard][id]info
	DocInfoGroup = make(map[int]*types.DocInfosShard)
)
View Source
var (
	// InvertedIndexGroup 反向索引表([shard][关键词]反向索引表)
	InvertedIndexGroup = make(map[int]*types.InvertedIndexShard)
)

Functions

func AddDocInfo

func AddDocInfo(shard int, docId string, docinfo *types.DocInfo)

AddDocInfo add documents info

func AddDocInfosShard

func AddDocInfosShard(shard int)

AddDocInfosShard add document infos shard

func AddInvertedIndexShard

func AddInvertedIndexShard(shard int)

AddInvertedIndexShard add inverted index shard

func AddKeywordIndices

func AddKeywordIndices(shard int, keyword string, keywordIndices *types.KeywordIndices)

AddKeywordIndices add keyword indices

func Asc

func Asc(data []uint64)

Asc asc

func Desc

func Desc(data []uint64)

Desc desc

func IsDocExist

func IsDocExist(docId string) bool

IsDocExist doc is exist

func IsSortedAsc

func IsSortedAsc(data []uint64) bool

IsSortedAsc sorted by Asc

func IsSortedDesc

func IsSortedDesc(data []uint64) bool

IsSortedDesc sorted by Desc

func StableAsc

func StableAsc(data []uint64)

StableAsc stable Asc

func StableDesc

func StableDesc(data []uint64)

StableDesc stable desc

Types

type Indexer

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

Indexer 索引器

func (*Indexer) AddDocToCache

func (indexer *Indexer) AddDocToCache(doc *types.DocIndex, forceUpdate bool)

AddDocToCache 向 ADDCACHE 中加入一个文档

func (*Indexer) AddDocs

func (indexer *Indexer) AddDocs(docs *types.DocsIndex)

AddDocs 向反向索引表中加入 ADDCACHE 中所有文档

func (*Indexer) AddTiKvDocs

func (indexer *Indexer) AddTiKvDocs(docs *types.DocsIndex)

func (*Indexer) HasDoc

func (indexer *Indexer) HasDoc(docId string) bool

HasDoc doc is exist return true

func (*Indexer) Init

func (indexer *Indexer) Init(options types.IndexerOpts)

Init 初始化索引器

func (*Indexer) LogicLookup

func (indexer *Indexer) LogicLookup(
	docIds map[string]bool, countDocsOnly bool, logicExpr []string,
	logic types.Logic) (docs []types.IndexedDoc, numDocs int)

LogicLookup logic Lookup

func (*Indexer) Lookup

func (indexer *Indexer) Lookup(
	tokens, labels []string, docIds map[string]bool, countDocsOnly bool,
	logic ...types.Logic) (docs []types.IndexedDoc, numDocs int)

Lookup lookup docs 查找包含全部搜索键(AND操作)的文档 当 docIds 不为 nil 时仅从 docIds 指定的文档中查找

func (*Indexer) RemoveDocToCache

func (indexer *Indexer) RemoveDocToCache(docId string, forceUpdate bool) bool

RemoveDocToCache 向 REMOVECACHE 中加入一个待删除文档 返回值表示文档是否在索引表中被删除

func (*Indexer) RemoveDocs

func (indexer *Indexer) RemoveDocs(docs *types.DocsId)

RemoveDocs 向反向索引表中删除 REMOVECACHE 中所有文档

func (*Indexer) RemoveTiKvDocs

func (indexer *Indexer) RemoveTiKvDocs(docs *types.DocsId)

func (*Indexer) SetTikv

func (indexer *Indexer) SetTikv(t *tikv.Tikv, prefix string)

type KeywordIndexKv

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

用于存储于K-V结构

type KeywordIndices

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

KeywordIndices 反向索引表的一行,收集了一个搜索键出现的所有文档,按照DocId从小到大排序。

type Ranker

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

Ranker ranker

func (*Ranker) AddDoc

func (ranker *Ranker) AddDoc(

	docId string, fields interface{}, content ...interface{})

AddDoc add doc 给某个文档添加评分字段

func (*Ranker) AddTiKvDoc

func (ranker *Ranker) AddTiKvDoc(
	docId string, fields interface{})

func (*Ranker) GetTiKvDoc

func (ranker *Ranker) GetTiKvDoc(docId string) (interface{}, bool)

RemoveDoc 删除某个文档的评分字段

func (*Ranker) Init

func (ranker *Ranker) Init(onlyID ...bool)

Init init ranker

func (*Ranker) Rank

func (ranker *Ranker) Rank(docs []types.IndexedDoc,
	options types.RankOpts, countDocsOnly bool) (interface{}, int)

Rank rank docs 给文档评分并排序

func (*Ranker) RankDocID

func (ranker *Ranker) RankDocID(docs []types.IndexedDoc,
	options types.RankOpts, countDocsOnly bool) (types.ScoredIDs, int)

RankDocID rank docs by types.ScoredIDs

func (*Ranker) RankDocs

func (ranker *Ranker) RankDocs(docs []types.IndexedDoc,
	options types.RankOpts, countDocsOnly bool) (types.ScoredDocs, int)

RankDocs rank docs by types.ScoredDocs

func (*Ranker) RemoveDoc

func (ranker *Ranker) RemoveDoc(docId string)

RemoveDoc 删除某个文档的评分字段

func (*Ranker) RemoveTiKvDoc

func (ranker *Ranker) RemoveTiKvDoc(docId string)

RemoveDoc 删除某个文档的评分字段

func (*Ranker) SetTikv

func (ranker *Ranker) SetTikv(t *tikv.Tikv, prefix string)

Jump to

Keyboard shortcuts

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