Skip to main content
Memory Fragments

Search Memory

Returns the most relevant historical memories based on semantic search

POST
/memory_nodes/search
cURL
curl --request POST \
  --url 'https://dashscope.aliyuncs.com/api/v2/apps/memory/memory_nodes/search' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "user_id": "<string>",
  "query": "<string>",
  "max_results": 0,
  "rewrite": false,
  "rerank": false,
  "similarity_threshold": 0,
  "plan_version": "Pro"
}
'
{
  "request_id": "<string>",
  "memory_nodes": [
    {
      "memory_node_id": "<string>",
      "content": "<string>"
    }
  ]
}
Returns the most relevant historical memories to the current query based on semantic search. Supports query rewriting, result reranking, and similarity filtering.

Request parameters

ParameterTypeRequiredDescription
user_idstringYesMemory entity ID
querystringYesSearch query statement
max_resultsnumberNoMaximum number of results (1~100)
rewritebooleanNoWhether to rewrite the query to improve accuracy
rerankbooleanNoWhether to rerank results
similarity_thresholdnumberNoSimilarity threshold (0.01.0), recommended 0.50.7
plan_versionstringNoPro or Lite, defaults to Pro if not provided. Takes precedence over rerank
The Pro plan version enables Rerank for higher retrieval quality; the Lite plan version disables Rerank for lower cost. See Billing.

Code examples

curl -X POST https://dashscope.aliyuncs.com/api/v2/apps/memory/memory_nodes/search \
  --header "Authorization: Bearer $DASHSCOPE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "user_id": "user_001",
    "query": "我需要做什么?",
    "max_results": 10,
    "rewrite": true,
    "rerank": true,
    "similarity_threshold": 0.6
  }'

# response
{
  "memory_nodes": [
    {"content": "用户每天上午9点需要喝水提醒", "memory_node_id": "50b46e97..."},
    {"content": "用户明天10点需要整理会议纪要", "memory_node_id": "381cc694..."}
  ],
  "request_id": "a1b2c3d4-..."
}
To view all memories, use ListMemory.

Authorizations

string
header
required

Body

application/json
string
required

记忆实体 ID

string
required

检索查询语句

integer

最大返回数量(1~100)

boolean

是否改写查询

boolean

是否对结果重排

number

相似度阈值(0.0~1.0),建议 0.5~0.7

enum<string>

策略版本,不传默认 Pro

Pro,Lite

Response

200-application/json
string
object[]
Overview
Managed Agent API
Sandbox API
Flow Agent API
RAG API
Connector API
Framework Integration
Assistant API (Deprecating)
  • Overview