gomate

package module
v0.0.0-...-c3a8f4e Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

README

GoMate

Build Status Go Report Card Coverage

Implementation of Soulmate's full-text search algorithm in Go, using LedisDB backend. It can be adapted to use Redis (or any Redis-like system), by implementing the DB interface.

For an introduction to the algorithm, read this.

I wrote this package as a quick search implementation for GoSonic, but I decided to publish it as an independent, reusable library.

Watch this space for documentation and examples.

Documentation

Index

Constants

View Source
const (
	AggregateSum byte = 0
	AggregateMin byte = 1
	AggregateMax byte = 2
)
View Source
const (
	DefaultNamespace = "gomate-index"
	IdSetSuffix      = "all-ids"
	KeyChainSuffix   = "all-keys"
)
View Source
const (
	KindSet  = "S-"
	KindZSet = "Z-"
	KindHash = "H-"
)
View Source
const CacheTimeOut = 600

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	Zadd(key string, pairs ...ScorePair) error
	Zrem(key string, members ...string) error
	Zrange(key string, start int, stop int) ([]ScorePair, error)
	Zinterstore(destKey string, srcKeys []string, aggregate byte) (int64, error)
	Zclear(key string) (int64, error)
	Zkeyexists(key string) (bool, error)
	Zexpire(key string, duration int64) (int64, error)
	Sadd(key string, member ...string) (int64, error)
	Smembers(key string) ([]string, error)
	Sclear(key string) (int64, error)
	Hset(key, field, value string) (int64, error)
	Hmget(key string, fields ...string) ([]string, error)
	Hclear(key string) (int64, error)
}

func NewLedisEmbeddedDB

func NewLedisEmbeddedDB(db *ledis.DB) DB

type Indexer

type Indexer interface {
	Index(id string, doc string) error
	Remove(ids ...string) error
	Clear() error
}

func NewIndexer

func NewIndexer(db DB, namespace ...string) Indexer

type LedisEmbeddedDB

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

func (*LedisEmbeddedDB) Hclear

func (l *LedisEmbeddedDB) Hclear(key string) (int64, error)

func (*LedisEmbeddedDB) Hmget

func (l *LedisEmbeddedDB) Hmget(key string, fields ...string) ([]string, error)

func (*LedisEmbeddedDB) Hset

func (l *LedisEmbeddedDB) Hset(key, field, value string) (int64, error)

func (*LedisEmbeddedDB) Sadd

func (l *LedisEmbeddedDB) Sadd(key string, members ...string) (int64, error)

func (*LedisEmbeddedDB) Sclear

func (l *LedisEmbeddedDB) Sclear(key string) (int64, error)

func (*LedisEmbeddedDB) Smembers

func (l *LedisEmbeddedDB) Smembers(key string) ([]string, error)

func (*LedisEmbeddedDB) Zadd

func (l *LedisEmbeddedDB) Zadd(key string, pairs ...ScorePair) error

func (*LedisEmbeddedDB) Zclear

func (l *LedisEmbeddedDB) Zclear(key string) (int64, error)

func (*LedisEmbeddedDB) Zexpire

func (l *LedisEmbeddedDB) Zexpire(key string, duration int64) (int64, error)

func (*LedisEmbeddedDB) Zinterstore

func (l *LedisEmbeddedDB) Zinterstore(destKey string, srcKeys []string, aggregate byte) (int64, error)

func (*LedisEmbeddedDB) Zkeyexists

func (l *LedisEmbeddedDB) Zkeyexists(key string) (bool, error)

func (*LedisEmbeddedDB) Zrange

func (l *LedisEmbeddedDB) Zrange(key string, start int, stop int) ([]ScorePair, error)

func (*LedisEmbeddedDB) Zrem

func (l *LedisEmbeddedDB) Zrem(key string, members ...string) error

type ScorePair

type ScorePair struct {
	Score  int64
	Member string
}

type Searcher

type Searcher interface {
	Search(query string, min int, max int) ([]string, error)
}

func NewSearcher

func NewSearcher(db DB, namespace ...string) Searcher

Jump to

Keyboard shortcuts

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