Documentation
¶
Index ¶
- Constants
- func CombineWhereFilters(f1, f2 chroma.WhereFilter) chroma.WhereFilter
- func ObsidianURI(vaultName, filePath string) string
- func TagWhereClause(tag string) chroma.WhereClause
- type BatchIngestData
- type ChunkRecord
- type ChunkWindow
- type NoteContent
- type Result
- type Store
- func (s *Store) Backlinks(ctx context.Context, targetSlug string) ([]Result, error)
- func (s *Store) BatchIngest(ctx context.Context, data []BatchIngestData, staleSlugs []string) error
- func (s *Store) Close() error
- func (s *Store) Connections(ctx context.Context, seedSlug string, maxHops int) ([]Result, error)
- func (s *Store) DeleteNoteChunks(ctx context.Context, noteSlug string) error
- func (s *Store) DeleteNoteLinks(ctx context.Context, noteSlug string) error
- func (s *Store) GetChunkWindow(ctx context.Context, noteSlug string, chunkIndex int, windowSize int) (*ChunkWindow, error)
- func (s *Store) GetNote(ctx context.Context, slugOrPath string) (*NoteContent, error)
- func (s *Store) GetNoteHashes(ctx context.Context) (map[string]string, error)
- func (s *Store) GraphBoostedSearch(ctx context.Context, queryVec []float32, seedSlug string, boost float64, ...) ([]Result, error)
- func (s *Store) HiddenConnections(ctx context.Context, queryVec []float32, seedSlug string, limit int, ...) ([]Result, error)
- func (s *Store) IngestNote(ctx context.Context, noteSlug string, chunks []ChunkRecord, links []string) error
- func (s *Store) PopulateContext(ctx context.Context, results []Result, windowSize int)
- func (s *Store) Reset(ctx context.Context) error
- func (s *Store) SemanticSearch(ctx context.Context, queryVec []float32, limit int, topKPerNote int, ...) ([]Result, error)
- func (s *Store) SharedTags(ctx context.Context, noteSlug string, minShared int) ([]Result, error)
- func (s *Store) Stats(ctx context.Context) (map[string]int64, error)
- func (s *Store) TagSearch(ctx context.Context, tag string, limit int, whereFilter chroma.WhereFilter, ...) ([]Result, error)
- func (s *Store) UpsertChunks(ctx context.Context, chunks []ChunkRecord) error
- func (s *Store) UpsertLinks(ctx context.Context, noteSlug string, links []string) error
Constants ¶
const ( CollectionChunks = "nb_chunks" CollectionLinks = "nb_links" )
Variables ¶
This section is empty.
Functions ¶
func CombineWhereFilters ¶
func CombineWhereFilters(f1, f2 chroma.WhereFilter) chroma.WhereFilter
CombineWhereFilters safely combines two optional WhereFilters using And.
func ObsidianURI ¶
ObsidianURI builds an obsidian://open URI for a vault-relative file path.
func TagWhereClause ¶
func TagWhereClause(tag string) chroma.WhereClause
TagWhereClause constructs a Chroma Or filter matching tag against tag_0 through tag_19.
Types ¶
type BatchIngestData ¶
type BatchIngestData struct {
NoteSlug string
ChunkRecords []ChunkRecord
Links []string
}
type ChunkRecord ¶
type ChunkWindow ¶
type ChunkWindow struct {
MatchedIndex int `json:"matched_index"`
Texts []string `json:"texts"`
Indices []int `json:"indices"`
}
ChunkWindow contains a matched chunk with its surrounding context.
type NoteContent ¶
type NoteContent struct {
NoteSlug string `json:"note_slug"`
Title string `json:"title"`
FilePath string `json:"file_path"`
Tags []string `json:"tags,omitempty"`
Text string `json:"text"`
Chunks int `json:"chunks"`
}
NoteContent represents the complete reconstructed text and metadata of a note.
type Result ¶
type Result struct {
NoteSlug string `json:"note_slug"`
Title string `json:"title"`
FilePath string `json:"file_path"`
Score float64 `json:"score"`
IsPhantom bool `json:"is_phantom,omitempty"`
ChunkIndex int `json:"chunk_index,omitempty"`
Tags []string `json:"tags,omitempty"`
Extra string `json:"extra,omitempty"` // e.g. shared tags, hop count
HeadingPath string `json:"heading_path,omitempty"`
Text string `json:"text,omitempty"` // populated only when include-text is requested
Context []string `json:"context,omitempty"` // adjacent chunks when windowing is enabled
}
Result is one row returned by any query.
type Store ¶
type Store struct {
SkipAttachments bool
// contains filtered or unexported fields
}
Store wraps two ChromaDB collections.
func (*Store) BatchIngest ¶
BatchIngest atomically replaces all chunks and links for a batch of notes, and deletes stale notes. It uses a single mutex lock to serialize operations on the store.
func (*Store) Connections ¶
Connections finds notes reachable from seedSlug within maxHops. BFS implemented in Go (no recursive SQL needed).
func (*Store) DeleteNoteChunks ¶
DeleteNoteChunks removes all chunks belonging to a note (before re-ingest).
func (*Store) DeleteNoteLinks ¶
DeleteNoteLinks removes all outgoing links for a note.
func (*Store) GetChunkWindow ¶
func (s *Store) GetChunkWindow(ctx context.Context, noteSlug string, chunkIndex int, windowSize int) (*ChunkWindow, error)
GetChunkWindow fetches ±windowSize adjacent chunks around the given chunk index.
func (*Store) GetNote ¶
GetNote retrieves all chunks of a note and reconstructs its complete content.
func (*Store) GetNoteHashes ¶
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, includeText bool) ([]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, includeText bool) ([]Result, error)
HiddenConnections finds notes semantically similar to queryVec but NOT already linked to/from seedSlug.
func (*Store) IngestNote ¶
func (s *Store) IngestNote(ctx context.Context, noteSlug string, chunks []ChunkRecord, links []string) error
IngestNote atomically replaces all chunks and links for a single note. It holds the store mutex for the entire Delete→UpsertChunks→UpsertLinks sequence to prevent concurrent hnswlib modifications that corrupt the HNSW graph (assertion: inbound_connections_num[i] > 0).
func (*Store) PopulateContext ¶
PopulateContext fetches adjacent chunks for each result when windowSize > 0.
func (*Store) SemanticSearch ¶
func (s *Store) SemanticSearch(ctx context.Context, queryVec []float32, limit int, topKPerNote int, whereFilter chroma.WhereFilter, includeText bool) ([]Result, error)
SemanticSearch finds the most similar chunks to queryVec. Returns deduplicated chunks retaining up to topKPerNote chunks per note.
func (*Store) SharedTags ¶
SharedTags finds notes sharing at least minShared tags with noteSlug.
func (*Store) TagSearch ¶
func (s *Store) TagSearch(ctx context.Context, tag string, limit int, whereFilter chroma.WhereFilter, includeText bool) ([]Result, error)
TagSearch finds notes that match a specific tag name.
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.