sparse

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sparse provides sparse retrieval steps using BM25 algorithm.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Search(
	searcher interface {
		Search(ctx context.Context, query string, topK int) ([]*Result, error)
	},
	topK int,
	logger logging.Logger,
	metrics core.Metrics,
) pipeline.Step[*core.RetrievalContext]

Search creates a new BM25 sparse search step with logger and metrics.

Parameters:

  • searcher: sparse search implementation (BM25, etc.)
  • topK: number of results to retrieve (default: 10)
  • logger: structured logger (auto-defaults to NoopLogger if nil)
  • metrics: metrics collector (optional, can be nil)

Example:

p.AddStep(sparse.Search(searcher, 20, logger, metrics))

Types

type Result

type Result struct {
	Chunk *core.Chunk
	Score float64
}

Result represents a sparse search result.

Jump to

Keyboard shortcuts

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