Overview
Azen’s semantic search uses vector embeddings to find memories based on meaning, not just keywords. Search with natural language queries and get the most relevant results.Basic Search
Example Search
Request Parameters
query (required)
The search query as natural language text.
- Type:
string - Min length: 1 character
- Format: Plain text, natural language
"What are my hobbies?""preferences about food""meetings scheduled next week"
topK (optional)
Maximum number of results to return.
- Type:
number - Range: 1-50
- Default: 5
Setting
topK higher returns more results but may include less relevant matches.How Semantic Search Works
Query Embedding
Your query text is embedded using the same model used for memories (OpenAI text-embedding-3-small).
Vector Search
The query vector is compared against stored memory vectors in Pinecone using cosine similarity.
Implementation Reference
Fromapps/api/src/routes/search.ts:
Understanding Search Results
Memory Objects
Each memory in thememories array contains:
id: Unique memory identifier (UUID)content: Decrypted memory textmetadata: Optional metadata (currently null)createdAt: ISO 8601 timestampembedded: Whether embedding is complete (always true in search results)
Raw Matches
TherawMatches array provides vector search details:
id: Memory ID with chunk index (e.g.,memoryId::0)score: Cosine similarity score (0-1, higher is better)values: Empty array (vector values not returned)
Similarity scores above 0.7 typically indicate strong relevance. Scores below 0.5 may be coincidental.
Search Strategies
Specific Queries
Ask specific questions for precise results:Broad Discovery
Use general terms to explore related memories:Contextual Search
Include context in your query:Filtering Search Results
Currently, Azen searches across all memories in your organization. To filter results:- Client-side filtering: Filter the returned memories by date, content patterns, etc.
- Multiple queries: Run separate queries for different topics
- Metadata tags (coming soon): Tag memories for category-based filtering
Handling No Results
If no relevant memories are found:- No memories have been embedded yet (check
embeddedfield) - Query doesn’t match any stored content semantically
- All memories are below the similarity threshold
Error Handling
Invalid Request (400)
Missing or invalid query:query field is a non-empty string and topK (if provided) is between 1-50.
Embedding Failure (500)
Performance Considerations
Search Latency
Typical search latency breakdown:- Query embedding: ~50-200ms
- Vector search (Pinecone): ~50-150ms
- Database fetch + decryption: ~20-100ms
- Total: ~120-450ms
Latency increases with
topK due to more database fetches and decryption operations.Search Quality
For best results:- Store memories with clear, descriptive content
- Keep individual memories focused on single topics
- Use consistent terminology across related memories
- Avoid very short memories (< 10 characters)
Usage Tracking
Search requests are automatically tracked:- Each successful
POST /api/v1/memory/searchincrementssearchCount - Failed requests increment
errorCount - Tracking is per organization, per API key, per day
Advanced Use Cases
Conversational Context
Build conversation context by searching recent messages:Personalization
Find user preferences for personalized experiences:Knowledge Retrieval
Search a knowledge base for relevant information:Next Steps
Semantic Search Concepts
Learn how vector embeddings work
Create Memories
Store memories to search
List All Memories
Browse memories with pagination
Search API Reference
Complete search endpoint documentation

