search

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package search implements the SQLite search store for Cortex.

It provides FTS5-based full-text search with BM25 ranking, topic key direct lookup, RRF fusion for hybrid search, and snippet extraction. The store implements the domain.SearchRepository interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GraphEdgeProvider added in v1.0.0

type GraphEdgeProvider interface {
	GetEdgesValidAt(ctx context.Context, obsID int64, at time.Time) ([]*domain.Edge, error)
	GetEdgesForObservation(ctx context.Context, obsID int64) ([]*domain.Edge, error)
}

Store implements the SQLite search store. It provides FTS5-based full-text search with advanced features. GraphEdgeProvider is an optional interface for temporal edge filtering. When set, graph neighbor expansion respects temporal validity.

type Store

type Store struct {
	Graph GraphEdgeProvider // Optional; enables temporal-aware graph expansion
	// contains filtered or unexported fields
}

Store implements FTS5-based search for Cortex.

func NewStore

func NewStore(db *sql.DB) *Store

NewStore creates a new search store with the given database connection.

func (*Store) GetSnippet

func (s *Store) GetSnippet(ctx context.Context, query string, content string, maxLength int) (string, error)

GetSnippet extracts a snippet from the content that matches the query. It uses FTS5's snippet() function to highlight matching terms.

func (*Store) Search

func (s *Store) Search(ctx context.Context, query string, opts domain.SearchOptions) ([]*domain.SearchResult, error)

Search performs a full-text search with the given query and options. It supports:

  • FTS5 keyword search with BM25 ranking
  • Topic key direct lookup (queries containing '/')
  • RRF fusion for combining topic key and keyword results
  • Snippet extraction using FTS5 snippet() function
  • Column weighting (content 2x title)

Returns search results ordered by relevance (rank).

Jump to

Keyboard shortcuts

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