indexer

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: Apache-2.0 Imports: 4 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetImplSpecificOptions added in v0.3.6

func GetImplSpecificOptions[T any](base *T, opts ...Option) *T

GetImplSpecificOptions extract the implementation specific options from Option list, optionally providing a base options with default values. e.g.

myOption := &MyOption{
	Field1: "default_value",
}

myOption := model.GetImplSpecificOptions(myOption, opts...)

Types

type CallbackInput

type CallbackInput struct {
	// Docs is the documents to be indexed.
	Docs []*schema.Document
	// Extra is the extra information for the callback.
	Extra map[string]any
}

CallbackInput is the input for the indexer callback.

func ConvCallbackInput

func ConvCallbackInput(src callbacks.CallbackInput) *CallbackInput

ConvCallbackInput converts the callback input to the indexer callback input.

type CallbackOutput

type CallbackOutput struct {
	// IDs is the ids of the indexed documents returned by the indexer.
	IDs []string
	// Extra is the extra information for the callback.
	Extra map[string]any
}

CallbackOutput is the output for the indexer callback.

func ConvCallbackOutput

func ConvCallbackOutput(src callbacks.CallbackOutput) *CallbackOutput

ConvCallbackOutput converts the callback output to the indexer callback output.

type Indexer

type Indexer interface {
	// Store stores the documents.
	Store(ctx context.Context, docs []*schema.Document, opts ...Option) (ids []string, err error) // invoke
}

Indexer is the interface for the indexer. Indexer is used to store the documents.

type Option

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

Option is the call option for Indexer component.

func WithEmbedding

func WithEmbedding(emb embedding.Embedder) Option

WithEmbedding is the option to set the embedder for the indexer, which convert document to embeddings.

func WithSubIndexes

func WithSubIndexes(subIndexes []string) Option

WithSubIndexes is the option to set the sub indexes for the indexer.

func WrapImplSpecificOptFn added in v0.3.6

func WrapImplSpecificOptFn[T any](optFn func(*T)) Option

WrapImplSpecificOptFn is the option to wrap the implementation specific option function.

type Options

type Options struct {
	// SubIndexes is the sub indexes to be indexed.
	SubIndexes []string
	// Embedding is the embedding component.
	Embedding embedding.Embedder
}

Options is the options for the indexer.

func GetCommonOptions

func GetCommonOptions(base *Options, opts ...Option) *Options

GetCommonOptions extract indexer Options from Option list, optionally providing a base Options with default values. e.g.

indexerOption := &IndexerOption{
	SubIndexes: []string{"default_sub_index"}, // default value
}

indexerOption := indexer.GetCommonOptions(indexerOption, opts...)

Jump to

Keyboard shortcuts

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