Documentation
¶
Overview ¶
A tag indexing & searching system.
Index ¶
- Constants
- Variables
- type GetRedisConnFuncType
- type HighTagNotifyFuncType
- type Index
- func (index *Index) Init()
- func (index *Index) ItemCount(tags []string) int
- func (index *Index) Query(tags []string, start, stop int) (ids []uint64)
- func (index *Index) QueryOptions(tags []string, start, stop int, options *IndexOptions) (ids []uint64)
- func (index *Index) RandomSuggestTags(tags []string, count int) (sugs []string)
- func (index *Index) RelativeTags(tags []string, count int) (relative_tags []string)
- func (index *Index) RelativeTagsCount(tags []string) int
- func (index *Index) RelativeTagsOptions(tags []string, count int, options *IndexOptions) (relative_tags []string)
- func (index *Index) Remove(id uint64)
- func (index *Index) Update(id uint64)
- func (index *Index) WaitAllIndexingDone()
- type IndexOptions
- type Item
- type ItemLoadFuncType
- type Rule
- type SORT_BY
- type Tag
Constants ¶
const ( SORT_BY_SCORE = iota SORT_BY_DATE SORT_BY_OVERALL )
Variables ¶
var (
// To get reading / writing connections, tagstack is based on Redis & redigo.
GetReadConn, GetWriteConn GetRedisConnFuncType
// To notify if a new tag group becomes high.
HighTagNofityFunc HighTagNotifyFuncType
RedisShardMax int
)
var ( // Normal logger. Logger = log.New(os.Stdout, "[tagstack]", log.LstdFlags) // Debug logger. DebugLogger = log.New(ioutil.Discard, "", 0) )
Loggers.
Functions ¶
This section is empty.
Types ¶
type GetRedisConnFuncType ¶
type HighTagNotifyFuncType ¶
type HighTagNotifyFuncType func(tags []string)
type Index ¶
type Index struct {
// To describe what's this index about, for example: Blog / News
// And the string should be as short as possible, for the string is the prefix of all the keys in the redis database.
What string
// High Node Boundary:
// A parameter to balance between memory usage & search speed:
// the higher: the index size smaller & search slower.
// normally a value of 100 is Ok.
HighNodeBoundary int
// the rule of this index.
// please see type Rule struct for detail.
Rule *Rule
// Item loading funcation
ItemLoadFunc ItemLoadFuncType
// Optional: Enable this if you use 'RandomSuggestTags' method.
// Note: If the items usually have more than 20 tags, this SHOULD NOT be enabled, because this feature will slow down the indexing progress to a "minutes per update" level.
EnableRandomSuggestTags bool
// contains filtered or unexported fields
}
the index struct
func (*Index) Init ¶
func (index *Index) Init()
This should be called once the struct is configured properly.
func (*Index) QueryOptions ¶
func (index *Index) QueryOptions(tags []string, start, stop int, options *IndexOptions) (ids []uint64)
func (*Index) RandomSuggestTags ¶
Suggest some tag that
func (*Index) RelativeTags ¶
What's the most frequently used tags with the tags ? Blame my poor language, in another way: Suggest a group of tags depends on a given group of tags.
func (*Index) RelativeTagsCount ¶
Number of "relative tags".
func (*Index) RelativeTagsOptions ¶
func (index *Index) RelativeTagsOptions(tags []string, count int, options *IndexOptions) (relative_tags []string)
func (*Index) Update ¶
Update an item: Note: If you are looking for: Create or New, use this instead. To reduce code complexity: we mix 2 kinds of request together: 1. Adding / Removing Tags 2. Update an item's score to affect the rank in searching. Update function will first remove old tags then refresh everything about the item together.
func (*Index) WaitAllIndexingDone ¶
func (index *Index) WaitAllIndexingDone()
When you wonder if all the indexing jobs are all done
type IndexOptions ¶
type Item ¶
type Item interface {
// The item's identifier in uint64.
Id() uint64
// The basic score / value of this item.
Score() float64
// What's the item's tag, and the scores.
// If there's no score among the tags, just pass scores with nil.
TagsWithScore() (tags []string, scores []float64)
// Whose item? the item id in uint64
WhoseId() uint64
// When did this item created.
CreateDate() uint64
}
What you should feed into this tag system.
type ItemLoadFuncType ¶
The function type the system load a item. (thread-safe)