Arcana.Search (Arcana v1.3.3)

View Source

Search functionality for Arcana.

Provides semantic, fulltext, and hybrid search modes with optional GraphRAG enhancement using Reciprocal Rank Fusion (RRF).

Summary

Functions

Rewrites a query using a provided rewriter function.

Searches for chunks similar to the query.

Functions

rewrite_query(query, opts \\ [])

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}

search(query, opts)

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: :semantic (default), :fulltext, or :hybrid
  • :collection - Filter results to a specific collection by name
  • :vector_store - Override the configured vector store backend
  • :semantic_weight - Weight for semantic scores in hybrid mode (default: 0.5)
  • :fulltext_weight - Weight for fulltext scores in hybrid mode (default: 0.5)