Documentation
¶
Overview ¶
Package bm25 provides BM25 (Best Matching 25) text search implementation.
Index ¶
- type Config
- type Document
- type Index
- func (idx *Index) Count() int
- func (idx *Index) Delete(ctx context.Context, id string) error
- func (idx *Index) Get(ctx context.Context, id string) (*Document, bool)
- func (idx *Index) Insert(ctx context.Context, doc Document) error
- func (idx *Index) InsertBatch(ctx context.Context, docs []Document) error
- func (idx *Index) Search(ctx context.Context, query string, k int) ([]ScoredDocument, error)
- func (idx *Index) SearchWithFilters(ctx context.Context, query string, k int, filters map[string]string) ([]ScoredDocument, error)
- type ScoredDocument
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// K1 controls term frequency saturation (default: 1.5).
// Higher values give more weight to term frequency.
K1 float64
// B controls document length normalization (default: 0.75).
// B=0 disables normalization, B=1 fully normalizes.
B float64
}
Config configures the BM25 index.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default BM25 configuration.
type Document ¶
type Document struct {
// ID is the unique document identifier.
ID string
// Content is the document text.
Content string
// Metadata contains additional document metadata.
Metadata map[string]string
}
Document represents a document in the index.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index implements a BM25 index for text search.
func (*Index) InsertBatch ¶
InsertBatch adds multiple documents to the index.
type ScoredDocument ¶
ScoredDocument represents a document with its BM25 score.
Click to show internal directories.
Click to hide internal directories.