store

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionChunks = "nb_chunks"
	CollectionLinks  = "nb_links"
)

Variables

This section is empty.

Functions

func ObsidianURI added in v1.1.0

func ObsidianURI(vaultName, filePath string) string

ObsidianURI builds an obsidian://open URI for a vault-relative file path.

Types

type ChunkRecord

type ChunkRecord struct {
	ID           string // "<slug>:<index>"
	NoteSlug     string
	Title        string
	FilePath     string
	ChunkIndex   int
	Text         string
	Tags         []string
	HasLinks     bool
	HeadingPath  string
	HeadingLevel int
	CodeBlocks   int
	HasTable     bool
	HasTask      bool
	ModifiedMs   int64
	ContentHash  string
	Embedding    []float32
}

type Result

type Result struct {
	NoteSlug string
	Title    string
	FilePath string
	Score    float64
	Extra    string // e.g. shared tags, hop count
}

Result is one row returned by any query.

type Store

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

Store wraps two ChromaDB collections.

func Open

func Open(ctx context.Context, path string) (*Store, error)

Open creates or opens the persistent ChromaDB store at path.

func (s *Store) Backlinks(ctx context.Context, targetSlug string) ([]Result, error)

Backlinks returns all notes that link TO targetSlug.

func (*Store) Close

func (s *Store) Close() error

Close releases all resources.

func (*Store) Connections

func (s *Store) Connections(ctx context.Context, seedSlug string, maxHops int) ([]Result, error)

Connections finds notes reachable from seedSlug within maxHops. BFS implemented in Go (no recursive SQL needed).

func (*Store) DeleteNoteChunks

func (s *Store) DeleteNoteChunks(ctx context.Context, noteSlug string) error

DeleteNoteChunks removes all chunks belonging to a note (before re-ingest).

func (*Store) GetNoteHashes

func (s *Store) GetNoteHashes(ctx context.Context) (map[string]string, error)

GetNoteHashes fetches the content_hash for all notes by reading chunk_index=0. Returns a map of note_slug -> content_hash.

func (*Store) GraphBoostedSearch

func (s *Store) GraphBoostedSearch(ctx context.Context, queryVec []float32, seedSlug string, boost float64, limit int) ([]Result, error)

GraphBoostedSearch runs semantic search, then boosts scores of notes directly linked to/from seedSlug.

func (*Store) HiddenConnections

func (s *Store) HiddenConnections(ctx context.Context, queryVec []float32, seedSlug string, limit int) ([]Result, error)

HiddenConnections finds notes semantically similar to queryVec but NOT already linked to/from seedSlug.

func (*Store) Reset

func (s *Store) Reset(ctx context.Context) error

Reset drops and recreates both collections. Used by `notebrain reset`.

func (*Store) SemanticSearch

func (s *Store) SemanticSearch(ctx context.Context, queryVec []float32, limit int, whereFilter chroma.WhereFilter) ([]Result, error)

SemanticSearch finds the most similar chunks to queryVec. Returns deduplicated notes (best chunk per note).

func (*Store) SharedTags

func (s *Store) SharedTags(ctx context.Context, noteSlug string, minShared int) ([]Result, error)

SharedTags finds notes sharing at least minShared tags with noteSlug.

func (*Store) Stats

func (s *Store) Stats(ctx context.Context) (map[string]int64, error)

Stats returns document counts for both collections.

func (*Store) UpsertChunks

func (s *Store) UpsertChunks(ctx context.Context, chunks []ChunkRecord) error

UpsertChunks stores a batch of chunks (upsert = insert or replace by ID). Call DeleteNoteChunks first to cleanly re-ingest a note.

func (s *Store) UpsertLinks(ctx context.Context, noteSlug string, links []string) error

UpsertLinks replaces all outgoing links for a note.

Jump to

Keyboard shortcuts

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