mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-12-04 00:07:24 +00:00
288 lines
5.5 KiB
Text
288 lines
5.5 KiB
Text
---
|
|
title: Search parameters
|
|
description: Complete reference for all search API parameters
|
|
---
|
|
|
|
## Required parameters
|
|
|
|
### q
|
|
|
|
<ParamField query="q" type="string" required>
|
|
The search query string. This is the text you want to search for in your memories and documents.
|
|
|
|
```json
|
|
{
|
|
"q": "What are John's machine learning preferences?"
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
## Search mode
|
|
|
|
### searchMode
|
|
|
|
<ParamField query="searchMode" type="enum" default="memories">
|
|
Controls the search behavior. Available options:
|
|
|
|
- `memories` (default): Searches only through memory entries
|
|
- `hybrid`: Searches memories first, then falls back to document chunks
|
|
|
|
**Hybrid mode behavior:**
|
|
- Searches memories and document chunks in parallel
|
|
- Merges results by similarity score
|
|
- Automatically deduplicates chunks already associated with memories
|
|
- Returns the most relevant results from both sources
|
|
|
|
```json
|
|
{
|
|
"q": "machine learning",
|
|
"searchMode": "hybrid"
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
## Result control
|
|
|
|
### limit
|
|
|
|
<ParamField query="limit" type="number" default={10}>
|
|
Maximum number of results to return. Must be between 1 and 100.
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"limit": 20
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
### threshold
|
|
|
|
<ParamField query="threshold" type="number" default={0.7}>
|
|
Minimum similarity score for results (0-1). Higher values return only more relevant results.
|
|
|
|
- `0.9-1.0`: Very high similarity (exact matches)
|
|
- `0.7-0.9`: High similarity (recommended)
|
|
- `0.5-0.7`: Moderate similarity
|
|
- `0.0-0.5`: Low similarity (may include irrelevant results)
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"threshold": 0.8
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
## Query optimization
|
|
|
|
### rerank
|
|
|
|
<ParamField query="rerank" type="boolean" default={false}>
|
|
Rerank results using a more sophisticated model for improved relevance. Adds ~200ms latency.
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"rerank": true
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
### rewriteQuery
|
|
|
|
<ParamField query="rewriteQuery" type="boolean" default={false}>
|
|
Rewrites the query to improve search results. Adds ~400ms latency.
|
|
|
|
Useful for:
|
|
- Ambiguous queries
|
|
- Queries with typos
|
|
- Queries that need clarification
|
|
|
|
```json
|
|
{
|
|
"q": "ml prefs",
|
|
"rewriteQuery": true
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
## Filtering
|
|
|
|
### filters
|
|
|
|
<ParamField query="filters" type="object">
|
|
Filter results by metadata conditions. Supports complex boolean logic.
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"filters": {
|
|
"and": [
|
|
{
|
|
"key": "category",
|
|
"operator": "equals",
|
|
"value": "user_preferences"
|
|
},
|
|
{
|
|
"key": "priority",
|
|
"operator": "greater_than",
|
|
"value": 5
|
|
}
|
|
]
|
|
}
|
|
}
|
|
```
|
|
|
|
See [Filtering](/search/filtering) for detailed documentation.
|
|
</ParamField>
|
|
|
|
### containerTag
|
|
|
|
<ParamField query="containerTag" type="string">
|
|
Filter results to a specific container tag. Useful for multi-tenant applications.
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"containerTag": "user_123"
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
## Include options
|
|
|
|
Control what additional data is included in the response.
|
|
|
|
### include.relatedMemories
|
|
|
|
<ParamField query="include.relatedMemories" type="boolean" default={false}>
|
|
Include memories that are related to the search results through memory relations (updates, extends, derives).
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"include": {
|
|
"relatedMemories": true
|
|
}
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
### include.forgottenMemories
|
|
|
|
<ParamField query="include.forgottenMemories" type="boolean" default={false}>
|
|
Include memories that have been marked as forgotten.
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"include": {
|
|
"forgottenMemories": true
|
|
}
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
### include.documents
|
|
|
|
<ParamField query="include.documents" type="boolean" default={false}>
|
|
Include document metadata (title, type, metadata) associated with memory results.
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"include": {
|
|
"documents": true
|
|
}
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
### include.summaries
|
|
|
|
<ParamField query="include.summaries" type="boolean" default={false}>
|
|
Include document summaries. Requires `include.documents` to be true.
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"include": {
|
|
"documents": true,
|
|
"summaries": true
|
|
}
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
### include.chunks
|
|
|
|
<ParamField query="include.chunks" type="boolean" default={false}>
|
|
Include the top 5 most relevant document chunks for each memory result.
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"include": {
|
|
"chunks": true
|
|
}
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
### include.temporalContext
|
|
|
|
<ParamField query="include.temporalContext" type="object">
|
|
Include memories created before and/or after each result.
|
|
|
|
```json
|
|
{
|
|
"q": "preferences",
|
|
"include": {
|
|
"temporalContext": {
|
|
"before": 3,
|
|
"after": 3
|
|
}
|
|
}
|
|
}
|
|
```
|
|
</ParamField>
|
|
|
|
## Complete example
|
|
|
|
```json
|
|
{
|
|
"q": "What are John's machine learning preferences?",
|
|
"searchMode": "hybrid",
|
|
"limit": 10,
|
|
"threshold": 0.75,
|
|
"rerank": true,
|
|
"rewriteQuery": false,
|
|
"containerTag": "user_john",
|
|
"filters": {
|
|
"and": [
|
|
{
|
|
"key": "category",
|
|
"operator": "equals",
|
|
"value": "preferences"
|
|
},
|
|
{
|
|
"key": "confidence",
|
|
"operator": "greater_than",
|
|
"value": 0.8
|
|
}
|
|
]
|
|
},
|
|
"include": {
|
|
"relatedMemories": true,
|
|
"forgottenMemories": false,
|
|
"documents": true,
|
|
"summaries": true,
|
|
"chunks": true,
|
|
"temporalContext": {
|
|
"before": 2,
|
|
"after": 2
|
|
}
|
|
}
|
|
}
|
|
```
|