Search functionality for Arcana.
Provides vector, keyword, and hybrid search modes with optional GraphRAG enhancement using Reciprocal Rank Fusion (RRF).
Mode names
Canonical mode atoms are :vector, :keyword, and :hybrid. The
old names :semantic and :fulltext are still accepted as aliases
for :vector and :keyword respectively, with a deprecation warning
logged on use. The old names will be removed in a future release.
Summary
Functions
Normalizes a search mode atom. Accepts the canonical :vector,
:keyword, :hybrid or the deprecated aliases :semantic and
:fulltext (with a one-line warning). Unknown values pass through
unchanged so the caller's validation surfaces them with context.
Rewrites a query using a provided rewriter function.
Searches for chunks similar to the query.
Functions
Normalizes a search mode atom. Accepts the canonical :vector,
:keyword, :hybrid or the deprecated aliases :semantic and
:fulltext (with a one-line warning). Unknown values pass through
unchanged so the caller's validation surfaces them with context.
Rewrites a query using a provided rewriter function.
Query rewriting can improve retrieval by expanding abbreviations, adding synonyms, or reformulating the query for better matching.
Options
:rewriter- A function that takes a query and returns {:ok, rewritten} or {:error, reason}
Searches for chunks similar to the query.
Returns {:ok, results} where results is a list of maps containing chunk
information and similarity scores, or {:error, reason} on failure.
Options
:repo- The Ecto repo to use (required for pgvector backend):limit- Maximum number of results (default: 10):source_id- Filter results to a specific source:threshold- Minimum similarity score (default: 0.0):mode- Search mode::vector(default),:keyword, or:hybrid.:semanticand:fulltextare deprecated aliases.:collection- Filter results to a specific collection by name:vector_store- Override the configured vector store backend:vector_weight- Weight for vector scores in hybrid mode (default: 0.5):keyword_weight- Weight for keyword scores in hybrid mode (default: 0.5):reranker- Reranker module or function. Defaults toconfig :arcana, :reranker. Passfalseto disable a globally configured reranker for this call. When set, retrieveslimit * over_fetchcandidates, reranks, returns toplimit.
Defaults for :limit, :threshold, and :mode can be set globally:
config :arcana, search: [limit: 10, threshold: 0.0, mode: :vector]