vectordb

package
v0.0.11-beta.6 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package vectordb provides an embedded TF-IDF / cosine-similarity vector index for semantic log search. It is a pure-Go, no-CGO, in-process accelerator. The relational DB remains the source of truth; this index is fully rebuildable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

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

Index is a thread-safe in-memory TF-IDF vector index for log bodies. Only ERROR and WARN logs are indexed to keep it small and relevant.

func New

func New(maxSize int) *Index

New creates a new Index with the given maximum entry cap.

func (*Index) Add

func (idx *Index) Add(logID uint, serviceName, severity, body string)

Add adds a log to the index. Thread-safe.

func (*Index) Search

func (idx *Index) Search(query string, k int) []SearchResult

Search finds the top-k logs most similar to the query string.

func (*Index) Size

func (idx *Index) Size() int

Size returns the current number of indexed documents.

type LogVector

type LogVector struct {
	LogID       uint
	ServiceName string
	Severity    string
	Body        string
	// contains filtered or unexported fields
}

LogVector represents an indexed log entry.

type SearchResult

type SearchResult struct {
	LogID       uint
	ServiceName string
	Severity    string
	Body        string
	Score       float64 // cosine similarity 0.0–1.0
}

SearchResult is a single similarity hit.

Jump to

Keyboard shortcuts

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