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
string
required
Search query string. Use natural language or specific keywords.
string
default:""
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
integer
default:"10"
Maximum number of results to return.
float
default:"None"
Minimum relevance score (0-1). Filters out low-quality matches.
Dict[str, Any]
default:"None"
Additional metadata filters for constraining results.
Response Structure
Returns aFindResult object:
List[MatchedContext]
Matched memory contexts.
List[MatchedContext]
Matched resource contexts.
List[MatchedContext]
Matched skill contexts.
integer
Total number of matches.
MatchedContext Structure
string
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
ContextType
Type:
memory, resource, or skill.integer
Context layer:
0: L0 (abstract)1: L1 (overview)2: L2 (content)
string
L0 abstract - concise summary.
float
Relevance score (0-1). Combines semantic similarity with hotness.
string
Context category or classification.
List[RelatedContext]
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()
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
