search

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

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

Go to latest
Published: May 13, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	// Mandatory fields
	ID         string
	Type       string
	Label      string
	Gain       float64
	CreatedAt  time.Time
	UpdatedAt  time.Time
	ArchivedAt time.Time

	// Other fields ([0] = key, [1] = value)
	Fields [][2]string
}

Document represents a indexable document, or a document retrieved from index in a search results.

func (Document) GetAllOfField

func (d Document) GetAllOfField(key string) (res []string)

func (Document) GetField

func (d Document) GetField(key string) (string, bool)

type Hit

type Hit struct {
	Document
	Score float64
}

type Index

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

Index represents a search index that can index and query Documents.

func Open

func Open(dir string) (*Index, error)

Open creates the Index on disk and make it ready for indexing and querying.

func OpenMem

func OpenMem() (*Index, error)

OpenMem creates an in-memory index usefull for testing

func (*Index) Close

func (idx *Index) Close() error

func (*Index) Search

func (idx *Index) Search(ctx context.Context, q string, opt QueryOptions) (Results, error)

func (*Index) Store

func (idx *Index) Store(docs ...Document) error

type Indexer

type Indexer struct {
	DB        *sqlitex.Pool
	Idx       *Index
	BatchSize int
	// contains filtered or unexported fields
}

func (*Indexer) Name

func (i *Indexer) Name() string

func (*Indexer) Run

func (i *Indexer) Run(ctx context.Context, w io.Writer) error

type QueryOptions

type QueryOptions struct {
	Type         string
	SortBy       string
	SortDir      string
	Limit        int
	InclArchived bool
}

type Results

type Results struct {
	Hits  []Hit
	Total uint64
	Time  time.Duration
}

Jump to

Keyboard shortcuts

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