Overview
Thefind() method performs fast semantic search using vector similarity. It’s optimized for simple queries where you don’t need session context or intent analysis.
Key Differences from search():
- No Intent Analysis: Direct vector similarity search
- No Session Context: Stateless, doesn’t use conversation history
- Faster: Lower latency due to simpler pipeline
- Simple Queries: Best for straightforward lookup tasks
Basic Usage
Parameters
Search query string. Use natural language or specific keywords.
Limit search to specific Viking URI prefix. Examples:
viking://resources/- Search only resourcesviking://user/memories/- Search user memoriesviking://skills/- Search available skillsviking://resources/my-project/- Search specific project
Maximum number of results to return.
Minimum relevance score (0-1). Filters out low-quality matches.
Additional metadata filters for constraining results.
Response Structure
Returns aFindResult object:
Matched memory contexts.
Matched resource contexts.
Matched skill contexts.
Total number of matches.
MatchedContext Structure
Viking URI of the matched context. May include level suffix:
.abstract.md- L0 directory abstract.overview.md- L1 directory overview- No suffix - L2 file content
Type:
memory, resource, or skill.Context layer:
0: L0 (abstract)1: L1 (overview)2: L2 (content)
L0 abstract - concise summary.
Relevance score (0-1). Combines semantic similarity with hotness.
Context category or classification.
Related contexts with URIs and abstracts.
Examples
Basic Search
Search with Target URI
Search with Score Threshold
Progressive Content Loading
HTTP API Example
Retrieval Strategy
Hierarchical Directory-Recursive Search
OpenViking uses a unique hierarchical retrieval strategy:-
Global Starting Points
- Performs global vector search to identify relevant directories
- Uses context_type to determine root namespaces (resources, memories, skills)
- Merges global results with explicit target_uri directories
-
Recursive Directory Exploration
- Starts from identified directories
- Searches children at each level using vector similarity
- Propagates scores from parent to child (weighted by
SCORE_PROPAGATION_ALPHA = 0.5) - Recurses into directories (L0/L1), treats files (L2) as terminal
-
Score Calculation
-
Convergence
- Tracks top-k results across rounds
- Stops when top-k stabilizes for 3 consecutive rounds
- Deduplicates by URI (keeps highest score)
Vector Search Types
- Dense Vectors: Semantic embeddings for meaning-based search
- Sparse Vectors: Keyword-based sparse embeddings (if available)
- Hybrid: Combines dense + sparse for best results
Context Layers
Results can come from any layer:- L0 (Abstract): Directory summaries - quick overviews
- L1 (Overview): Directory content summaries
- L2 (Content): Full file content - detailed information
When to Use find() vs search()
| Scenario | Best Method |
|---|---|
| Quick lookup | find() |
| No conversation context | find() |
| Need speed | find() |
| Conversational search | search() |
| Multi-turn dialogue | search() |
| Complex intent | search() |
Working with Results
Iterating Over All Results
Accessing Related Contexts
Understanding Scores
Best Practices
-
Use Specific Queries: More specific queries yield better results
-
Scope Your Search: Use
target_urito search in relevant namespaces -
Filter by Score: Set thresholds to get quality matches
-
Progressive Loading: Start with abstracts, load more as needed
-
Leverage Relations: Follow related contexts for comprehensive information
Performance
- Latency: ~50-100ms for typical queries
- Scalability: Handles millions of contexts efficiently
- Caching: Embeddings are cached for repeated queries
- Convergence: Usually converges in 2-3 directory levels
Related Methods
- search() - Context-aware search with session support
- abstract() - Read L0 abstracts
- overview() - Read L1 overviews
- read() - Read L2 full content
