storage

package
v0.0.0-...-b0e2820 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	ID          int64
	DocumentID  int64
	ChunkIndex  int
	Content     string
	StartOffset int
	EndOffset   int
	Embedding   []float32
}

Chunk represents a text chunk with its embedding

type Database

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

Database handles SQLite operations with vector search

func NewDatabase

func NewDatabase(dbPath string) (*Database, error)

NewDatabase creates a new database connection and initializes schema Note: sqlite_vec.Auto() must be called before creating the database

func (*Database) Close

func (d *Database) Close() error

Close closes the database connection

func (*Database) DeleteDocument

func (d *Database) DeleteDocument(source string) error

DeleteDocument deletes a document and its chunks by source

func (*Database) DocumentExists

func (d *Database) DocumentExists(source string) (bool, error)

DocumentExists checks if a document exists by source

func (*Database) IndexDocument

func (d *Database) IndexDocument(source, sourceType, title string, chunks []Chunk) error

IndexDocument stores a document with its chunks and embeddings

func (*Database) ListDocuments

func (d *Database) ListDocuments(sourceTypeFilter string) ([]Document, error)

ListDocuments returns all indexed documents with optional source type filter

func (*Database) Search

func (d *Database) Search(queryEmbedding []float32, topK int, minScore float64, sourceFilter string) ([]SearchResult, error)

Search performs vector similarity search

type Document

type Document struct {
	ID          int64
	Source      string
	SourceType  string
	IndexedAt   time.Time
	ContentSize int
	ChunkCount  int
	Title       string
}

Document represents a document in the database

type SearchResult

type SearchResult struct {
	Content    string
	Source     string
	ChunkIndex int
	Score      float64
}

SearchResult represents a search result

Jump to

Keyboard shortcuts

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