search

package module
v0.0.0-...-6a25a8b Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultStopWords = map[string]bool{
	"a": true, "an": true, "and": true, "are": true, "as": true, "at": true, "be": true, "but": true,
	"by": true, "for": true, "if": true, "in": true, "into": true, "is": true, "it": true,
	"no": true, "not": true, "of": true, "on": true, "or": true, "such": true, "that": true,
	"the": true, "their": true, "then": true, "there": true, "these": true,
	"they": true, "this": true, "to": true, "was": true, "will": true, "with": true,
}

DefaultStopWords contains common English words to filter out (similar to Lucene's default stop words).

Functions

This section is empty.

Types

type Index

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

Index is the main entry point for the text search engine.

func NewIndex

func NewIndex(ctx context.Context, config sop.DatabaseOptions, t sop.Transaction, name string) (*Index, error)

NewIndex creates or opens a text search index.

func (*Index) Add

func (idx *Index) Add(ctx context.Context, docID string, text string) error

Add indexes a document.

func (*Index) Search

func (idx *Index) Search(ctx context.Context, query string) ([]TextSearchResult, error)

Search performs a BM25 search.

type SimpleTokenizer

type SimpleTokenizer struct{}

SimpleTokenizer splits text by whitespace and punctuation, converting to lowercase.

func (*SimpleTokenizer) Tokenize

func (t *SimpleTokenizer) Tokenize(text string) []string

type TextSearchResult

type TextSearchResult struct {
	DocID string
	Score float64
}

TextSearchResult represents a scored document from text search.

type Tokenizer

type Tokenizer interface {
	Tokenize(text string) []string
}

Tokenizer defines the interface for splitting text into terms.

Jump to

Keyboard shortcuts

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