Function Signature
Purpose
Usessub_questions if present (from decompose step), otherwise uses the original question. Searches the selected collections and populates results.
Parameters
The agent context from the pipeline
Options for the search step
Options
Custom searcher module or function (default:
Arcana.Agent.Searcher.Arcana)- Module: Must implement
search/3callback - Function: Signature
fn question, collection, opts -> {:ok, chunks} | {:error, reason} end
Single collection name to searchTakes precedence over
:collections and ctx.collections.List of collection names to searchTakes precedence over
ctx.collections.Enable self-correcting search (default: false)Note: This option is parsed but not currently implemented in the search step. Use
reason/2 for multi-hop reasoning instead.Max retry attempts for self-correct (default: 3)Note: Currently unused. See
reason/2 for iterative search.Custom prompt function
fn question, chunks -> prompt_string endNote: Currently unused. See reason/2 for sufficiency evaluation.Custom prompt function for query rewritingNote: Currently unused. See
reason/2 for iterative search.Context Updates
Search results. Each result contains:
question- The query that was searchedcollection- The collection that was searchedchunks- List of retrieved chunks withid,text, andscore
Collection Selection Priority
Collections are determined in this order::collectionoption (single collection):collectionsoption (multiple collections)ctx.collections(set byselect/2)- Fallback:
["default"]
Examples
Basic Search
Search Specific Collection
Search Multiple Collections
With LLM-Based Collection Selection
With Decomposition
With Query Expansion
Complete Pipeline
Custom Searcher Module
Inline Searcher Function
Hybrid Search
Skip Retrieval
Ifgate/2 sets skip_retrieval: true, search returns empty results:
Custom Searcher Behaviour
id- Unique identifiertext- The chunk contentscore- Relevance score (optional)
Search Options Passed to Searcher
The searcher receives these options from context:Telemetry Event
Emits[:arcana, :agent, :search] with metadata:
Performance Considerations
- Total searches =
sub_questions × collections - With 3 sub-questions and 2 collections = 6 searches
- Consider limiting sub-questions and collections
- Use
reason/2for iterative search instead of upfront decomposition
See Also
- decompose/2 - Creates sub-questions
- select/2 - Chooses collections
- reason/2 - Multi-hop iterative search
- rerank/2 - Improve result quality
- answer/2 - Generate answer from results