index

package
v0.0.0-...-0a5fad8 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned by the indexer when attempting to look up a document that does not exist.
	ErrNotFound = errors.New("not found")

	// ErrMissingLinkID is returned when attempting to index a document that does not specify a valid link ID
	ErrMissingLinkID = errors.New("document does not provide a valid linkID")
)

Functions

This section is empty.

Types

type Document

type Document struct {
	LinkID    uuid.UUID
	URL       string
	Title     string
	Content   string
	IndexedAt time.Time
	PageRank  float64
}

Document describes a web page whose content has been indexed by this service

type Indexer

type Indexer interface {
	Index(doc *Document) error
	FindByID(linkID uuid.UUID) (*Document, error)
	Search(query Query) (Iterator, error)
	UpdateScore(linkID uuid.UUID, score float64) error
}

Indexer is implemented by objects that can index and search documents discovered

type Iterator

type Iterator interface {
	Close() error
	Next() bool
	Error() error
	Document() *Document
	TotalCount() uint64
}

Iterator is implemented by objects that can paginate search results

type Query

type Query struct {
	Type       QueryType // the way indexer should interpret the search expression
	Expression string    // the search expression
	Offset     uint64
}

Query contains a set of parameters to use when searching indexed documents

type QueryType

type QueryType uint8
const (
	QueryTypeMatch  QueryType = iota // QueryTypeMatch requests the indexer to match each expression term.
	QueryTypePhrase                  // QueryTypePhrase searches for an exact phrase match.
)

Jump to

Keyboard shortcuts

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