engine

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2019 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterOpts

type ClusterOpts struct {
	Port  string
	Peers []string
}

ClusterOpts denotes Lens database clustering options

type DocData

type DocData struct {
	Content    string             `json:"content"`
	Metadata   *models.MetaDataV2 `json:"metadata"`
	Properties *DocProps          `json:"properties"`
}

DocData defines the structure of indexed objects

type DocProps

type DocProps struct {
	Indexed string `json:"indexed"` // date indexed
}

DocProps denotes additional information about a document

type Document

type Document struct {
	Object  *models.ObjectV2
	Content string
	Reindex bool
}

Document denotes a document to index

type Engine

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

Engine implements Lens V2's core search functionality

func New

func New(l *zap.SugaredLogger, opts Opts) (*Engine, error)

New instantiates a new Engine

func (*Engine) Close

func (e *Engine) Close()

Close shuts down the engine

func (*Engine) Index

func (e *Engine) Index(doc Document) error

Index stores the given object

func (*Engine) IsIndexed

func (e *Engine) IsIndexed(hash string) bool

IsIndexed checks if the given content hash has already been indexed

func (*Engine) Remove

func (e *Engine) Remove(hash string) error

Remove deletes an indexed object from the engine

func (*Engine) Run

func (e *Engine) Run()

Run starts any additional processes required to maintain the engine

func (*Engine) Search

func (e *Engine) Search(ctx context.Context, q Query) ([]Result, error)

Search performs a query

type Opts

type Opts struct {
	StorePath string
	Queue     queue.Options
}

Opts denotes options for the Lens engine

type Query

type Query struct {
	Text     string
	Required []string

	// Query metadata
	Tags       []string
	Categories []string
	MimeTypes  []string

	// Hashes restricts what documents to include in query - this is only a
	// filtering option, so some other query fields must be provided as well
	Hashes []string
}

Query denotes options for a search

func (*Query) Hash

func (q *Query) Hash() string

Hash generates a checksum hash for the query

type Result

type Result struct {
	Hash string
	MD   models.MetaDataV2

	Score float64
}

Result denotes a found document

type Searcher

type Searcher interface {
	Index(doc Document) error
	Search(ctx context.Context, query Query) ([]Result, error)

	IsIndexed(hash string) bool
	Remove(hash string) error

	Close()
}

Searcher exposes Engine's primary functions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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