index

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package index implements a search index.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocID

type DocID string

DocID is a unique identifier of a document in an index.

type Document

type Document struct {
	ID    DocID  // the document ID
	Title string // the document title
	URL   string // the document URL
	Data  []byte // the text content
}

Document is a document to be indexed.

type DocumentResult

type DocumentResult struct {
	Document
	Score float64
}

DocumentResult is the result of a search for a single document.

type Index

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

Index is a search index.

func New

func New() (*Index, error)

New returns a new index.

func (*Index) Add

func (i *Index) Add(ctx context.Context, doc Document) error

Add adds a document to the index.

func (*Index) Search

func (i *Index) Search(query query.Query) (*Result, error)

Search performs a search against the index.

type Result

type Result struct {
	DocumentResults []DocumentResult // document results
	Total           int              // total number of document results
}

Result is the result of a search.

Jump to

Keyboard shortcuts

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