Skip to main content
Search through your memories and documents with a single API call.
Use searchMode: "hybrid" for best results. It searches both memories and document chunks, returning the most relevant content.

Quick Start

import Supermemory from 'supermemory';

const client = new Supermemory();

const results = await client.search({
  q: "machine learning",
  containerTag: "user_123",
  searchMode: "hybrid",
  limit: 5
});

results.results.forEach(result => {
  console.log(result.content, result.similarity);
});
Response:
{
  "results": [
    {
      "id": "mem_xyz",
      "content": "User is interested in machine learning for product recommendations",
      "similarity": 0.91,
      "metadata": { "topic": "interests" }
    },
    {
      "id": "chunk_abc",
      "content": "Machine learning enables personalized experiences at scale...",
      "similarity": 0.87,
      "metadata": { "source": "onboarding_doc" }
    }
  ],
  "timing": 92,
  "total": 5
}

Parameters

ParameterTypeDefaultDescription
qstringrequiredSearch query
containerTagstringFilter by user/project
searchModestring"hybrid""hybrid" (recommended) or "memories"
limitnumber10Max results
threshold0-10.5Similarity cutoff (higher = fewer, better results)
rerankbooleanfalseRe-score for better relevance (+100ms)
filtersobjectMetadata filters (AND/OR structure)

Search Modes

  • hybrid (recommended) — Searches both memories and document chunks, returns the most relevant
  • memories — Only searches extracted memories
// Hybrid: memories + document chunks (recommended)
await client.search({
  q: "quarterly goals",
  containerTag: "user_123",
  searchMode: "hybrid"
});

// Memories only: just extracted facts
await client.search({
  q: "user preferences",
  containerTag: "user_123",
  searchMode: "memories"
});

Filtering

Filter by containerTag to scope results to a user or project:
const results = await client.search({
  q: "project updates",
  containerTag: "user_123",
  searchMode: "hybrid"
});
Use filters for metadata-based filtering:
const results = await client.search({
  q: "meeting notes",
  containerTag: "user_123",
  filters: {
    AND: [
      { key: "type", value: "meeting" },
      { key: "year", value: "2024" }
    ]
  }
});
  • String equality: { key: "status", value: "active" }
  • String contains: { filterType: "string_contains", key: "title", value: "react" }
  • Numeric: { filterType: "numeric", key: "priority", value: "5", numericOperator: ">=" }
  • Array contains: { filterType: "array_contains", key: "tags", value: "important" }
  • Negate: { key: "status", value: "draft", negate: true }
See Organizing & Filtering for full syntax.

Query Optimization

Reranking

Re-scores results for better relevance. Adds ~100ms latency.
const results = await client.search({
  q: "complex technical question",
  containerTag: "user_123",
  rerank: true
});

Threshold

Control result quality vs quantity:
// Broad search — more results
await client.search({ q: "...", threshold: 0.3 });

// Precise search — fewer, better results
await client.search({ q: "...", threshold: 0.8 });

Chatbot Example

Optimal configuration for conversational AI:
async function getContext(userId: string, message: string) {
  const results = await client.search({
    q: message,
    containerTag: userId,
    searchMode: "hybrid",
    threshold: 0.6,
    limit: 5
  });

  return results.results
    .map(r => r.content)
    .join('\n\n');
}
interface SearchResult {
  id: string;
  content: string;        // Memory or chunk content
  similarity: number;     // 0-1
  metadata: object | null;
  updatedAt: string;
}

interface SearchResponse {
  results: SearchResult[];
  timing: number;         // ms
  total: number;
}

Next Steps