Documentation
¶
Overview ¶
Package index orchestrates atomic Stroma index rebuilds and searches.
Index ¶
- type BuildOptions
- type BuildResult
- type RecordQuery
- type Reranker
- type SearchHit
- type SearchQuery
- type Section
- type SectionQuery
- type Snapshot
- func (s *Snapshot) Close() error
- func (s *Snapshot) Path() string
- func (s *Snapshot) Records(ctx context.Context, query RecordQuery) ([]corpus.Record, error)
- func (s *Snapshot) Search(ctx context.Context, query SnapshotSearchQuery) ([]SearchHit, error)
- func (s *Snapshot) SearchVector(ctx context.Context, query VectorSearchQuery) ([]SearchHit, error)
- func (s *Snapshot) Sections(ctx context.Context, query SectionQuery) ([]Section, error)
- func (s *Snapshot) Stats(ctx context.Context) (*Stats, error)
- type SnapshotSearchQuery
- type Stats
- type UpdateOptions
- type UpdateResult
- type VectorSearchQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildOptions ¶
type BuildOptions struct {
Path string
ReuseFromPath string
Embedder embed.Embedder
// MaxChunkTokens sets the approximate maximum number of tokens (words)
// per chunk. Sections that exceed this limit are split into smaller
// sub-sections. Zero disables token-budget splitting.
MaxChunkTokens int
// ChunkOverlapTokens sets the approximate number of overlapping tokens
// between adjacent sub-sections when a section is split. Zero disables
// overlap.
ChunkOverlapTokens int
// Quantization controls the vector storage format. Supported values
// are "float32" (default) and "int8". Int8 reduces storage by 4x at
// the cost of minor precision loss.
Quantization string
}
BuildOptions controls how a Stroma index is rebuilt.
type BuildResult ¶
type BuildResult struct {
Path string
RecordCount int
ChunkCount int
ReusedRecordCount int
ReusedChunkCount int
EmbeddedChunkCount int
EmbedderDimension int
EmbedderFingerprint string
ContentFingerprint string
}
BuildResult summarizes a completed rebuild.
func Rebuild ¶
func Rebuild(ctx context.Context, records []corpus.Record, options BuildOptions) (*BuildResult, error)
Rebuild atomically recreates the index at the requested path.
type RecordQuery ¶
RecordQuery filters records from an opened snapshot.
type Reranker ¶ added in v0.4.0
type Reranker interface {
Rerank(ctx context.Context, query string, candidates []SearchHit) ([]SearchHit, error)
}
Reranker optionally refines one search candidate shortlist before the final limit truncation.
type SearchHit ¶
type SearchHit struct {
ChunkID int64
Ref string
Kind string
Title string
SourceRef string
Heading string
Content string
Metadata map[string]string
Score float64
}
SearchHit is one retrieved section.
type SearchQuery ¶
type SearchQuery struct {
Path string
Text string
Limit int
Kinds []string
Embedder embed.Embedder
Reranker Reranker
}
SearchQuery defines one semantic search.
type Section ¶
type Section struct {
ChunkID int64
Ref string
Kind string
Title string
SourceRef string
Heading string
Content string
Metadata map[string]string
Embedding []float64
}
Section is one stored section from a Stroma snapshot.
type SectionQuery ¶
SectionQuery filters sections from an opened snapshot.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is one opened Stroma index snapshot.
func OpenSnapshot ¶
OpenSnapshot opens a read-only Stroma snapshot.
func (*Snapshot) Search ¶
Search runs a hybrid text search (vector + FTS5) against the opened snapshot.
func (*Snapshot) SearchVector ¶
SearchVector runs a vector search against the opened snapshot.
type SnapshotSearchQuery ¶
type SnapshotSearchQuery struct {
Text string
Limit int
Kinds []string
Embedder embed.Embedder
Reranker Reranker
}
SnapshotSearchQuery defines one text search against an opened snapshot.
type Stats ¶
type Stats struct {
Path string
RecordCount int
ChunkCount int
KindCounts map[string]int
SchemaVersion string
EmbedderDimension int
EmbedderFingerprint string
ContentFingerprint string
CreatedAt string
}
Stats describes a built Stroma index.
type UpdateOptions ¶ added in v0.4.0
type UpdateOptions struct {
Path string
Embedder embed.Embedder
// MaxChunkTokens sets the approximate maximum number of tokens (words)
// per chunk. It should match the chunking policy used to build the current
// index if callers want incremental updates to remain section-compatible.
MaxChunkTokens int
// ChunkOverlapTokens sets the approximate number of overlapping tokens
// between adjacent sub-sections when a section is split. It should match
// the chunking policy used to build the current index.
ChunkOverlapTokens int
// Quantization, when provided, must match the existing index. Leaving it
// empty reuses the stored quantization metadata.
Quantization string
}
UpdateOptions controls how an existing Stroma index is updated in place.
type UpdateResult ¶ added in v0.4.0
type UpdateResult struct {
Path string
UpsertedCount int
RemovedCount int
RecordCount int
ChunkCount int
ReusedRecordCount int
ReusedChunkCount int
EmbeddedChunkCount int
EmbedderDimension int
EmbedderFingerprint string
ContentFingerprint string
}
UpdateResult summarizes one incremental update.
func Update ¶ added in v0.4.0
func Update(ctx context.Context, added []corpus.Record, removed []string, options UpdateOptions) (*UpdateResult, error)
Update applies add, replace, and remove operations to an existing Stroma index without rebuilding it from scratch.
type VectorSearchQuery ¶
VectorSearchQuery defines one vector search against an opened snapshot.