Skip to main content

Overview

The find() 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 resources
  • viking://user/memories/ - Search user memories
  • viking://skills/ - Search available skills
  • viking://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 a FindResult 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

Search with Target URI

Search with Score Threshold

Progressive Content Loading

HTTP API Example

Response:

Retrieval Strategy

OpenViking uses a unique hierarchical retrieval strategy:
  1. 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
  2. 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
  3. Score Calculation
  4. 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

Working with Results

Iterating Over All Results

Understanding Scores

Best Practices

  1. Use Specific Queries: More specific queries yield better results
  2. Scope Your Search: Use target_uri to search in relevant namespaces
  3. Filter by Score: Set thresholds to get quality matches
  4. Progressive Loading: Start with abstracts, load more as needed
  5. 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