module
Memo::Search
Overview
Semantic search operations
Extended Modules
Defined in:
memo/search.crInstance Method Summary
-
#mark_as_read(db : DB::Database, chunk_ids : Array(Int64))
Mark chunks as read (increment read_count)
-
#semantic(db : DB::Database, embedding : Array(Float64), service_id : Int64, limit : Int32 = 10, min_score : Float64 = 0.7, filters : Filters | Nil = nil, detail : Symbol = :reference, sql_where : String | Nil = nil, projection_vectors : Array(Array(Float64)) | Nil = nil, projection_threshold : Float64 = 2.0, like : Array(String) | Nil = nil, match : String | Nil = nil, text_schema : String | Nil = nil, include_text : Bool = false) : Array(Result)
Semantic search by embedding
Instance Method Detail
Mark chunks as read (increment read_count)
Semantic search by embedding
Returns results ranked by cosine similarity
IMPORTANT: Must provide service_id to ensure embeddings are from same vector space
sql_where: Raw SQL fragment to filter chunks (e.g., for ATTACH queries). Example: "c.source_id IN (SELECT id FROM main.artifact WHERE kind = 'goal')"
like: Array of LIKE patterns for AND filtering by text content. Requires text_schema to be set.
match: FTS5 full-text search query (e.g., "cats OR dogs"). Requires text_schema to be set.
text_schema: Schema name for ATTACHed text database (e.g., "text_store"). Required for like, match, and include_text.
include_text: If true, includes text content in search results. Requires text_schema to be set.
projection_vectors: Random orthogonal vectors for fast pre-filtering. If provided, candidates are filtered by projection distance before computing full cosine similarity.
projection_threshold: Maximum squared distance in projection space. Candidates with projection distance > threshold are skipped. Default 2.0 is generous to avoid false negatives.