Documentation
¶
Overview ¶
Package index orchestrates atomic Stroma index rebuilds and searches.
Index ¶
- type BuildOptions
- type BuildResult
- type RecordQuery
- 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 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 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
}
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 ¶
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 VectorSearchQuery ¶
VectorSearchQuery defines one vector search against an opened snapshot.