apps/docs/search.mdx
Search through your memories and documents with a single API call.
<Tip> **Use `searchMode: "hybrid"`** for best results. It searches both memories and document chunks, returning the most relevant content. </Tip>const client = new Supermemory();
const results = await client.search.memories({
q: "machine learning",
containerTag: "user_123",
searchMode: "hybrid",
limit: 5
});
results.results.forEach(result => {
console.log(result.memory || result.chunk, result.similarity);
});
```
client = Supermemory()
results = client.search.memories(
q="machine learning",
container_tag="user_123",
search_mode="hybrid",
limit=5
)
for result in results.results:
print(result.memory or result.chunk, result.similarity)
```
Response:
{
"results": [
{
"id": "mem_xyz",
"memory": "User is interested in machine learning for product recommendations",
"similarity": 0.91,
"metadata": { "topic": "interests" },
"updatedAt": "2024-01-15T10:30:00.000Z",
"version": 1
},
{
"id": "chunk_abc",
"chunk": "Machine learning enables personalized experiences at scale...",
"similarity": 0.87,
"metadata": { "source": "onboarding_doc" },
"updatedAt": "2024-01-14T09:15:00.000Z",
"version": 1
}
],
"timing": 92,
"total": 5
}
| Parameter | Type | Default | Description |
|---|---|---|---|
q | string | required | Search query |
containerTag | string | — | Filter by user/project |
searchMode | string | "hybrid" | "hybrid" (recommended) or "memories" |
limit | number | 10 | Max results |
threshold | 0-1 | 0.5 | Similarity cutoff (higher = fewer, better results) |
rerank | boolean | false | Re-score for better relevance (+100ms) |
filters | object | — | Metadata filters (AND/OR structure) |
hybrid (recommended) — Searches both memories and document chunks, returns the most relevantmemories — Only searches extracted memories// Hybrid: memories + document chunks (recommended)
await client.search.memories({
q: "quarterly goals",
containerTag: "user_123",
searchMode: "hybrid"
});
// Memories only: just extracted facts
await client.search.memories({
q: "user preferences",
containerTag: "user_123",
searchMode: "memories"
});
Filter by containerTag to scope results to a user or project:
const results = await client.search.memories({
q: "project updates",
containerTag: "user_123",
searchMode: "hybrid"
});
Use filters for metadata-based filtering:
const results = await client.search.memories({
q: "meeting notes",
containerTag: "user_123",
filters: {
AND: [
{ key: "type", value: "meeting" },
{ key: "year", value: "2024" }
]
}
});
See Organizing & Filtering for full syntax. </Accordion>
Re-scores results for better relevance. Adds ~100ms latency.
const results = await client.search.memories({
q: "complex technical question",
containerTag: "user_123",
rerank: true
});
Control result quality vs quantity:
// Broad search — more results
await client.search.memories({ q: "...", threshold: 0.3 });
// Precise search — fewer, better results
await client.search.memories({ q: "...", threshold: 0.8 });
Optimal configuration for conversational AI:
async function getContext(userId: string, message: string) {
const results = await client.search.memories({
q: message,
containerTag: userId,
searchMode: "hybrid",
threshold: 0.6,
limit: 5
});
return results.results
.map(r => r.memory || r.chunk)
.join('\n\n');
}
interface SearchResponse { results: SearchResult[]; timing: number; // ms total: number; }
</Accordion>
---
## Next Steps
- [Ingesting Content](/add-memories) — Add content to search
- [User Profiles](/user-profiles) — Get user context with search
- [Organizing & Filtering](/concepts/filtering) — Container tags and metadata