search method performs a hybrid semantic search across stored memories and returns the most relevant results ranked by score. Call it before generating a response to give your agent relevant context from prior conversations.
Method signature
owner_id, agent_id, or session_id must be provided.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
query | str | Yes | Natural language search query. |
owner_id | str | Conditional | Filter by owner or user identifier. |
agent_id | str | Conditional | Filter by agent identifier. |
session_id | str | Conditional | Filter by session identifier. |
limit | int | No | Maximum number of results to return. |
cross_session | bool | No | Search across all sessions for the given owner. |
Response
Returns aList[CognisSearchResult]. Each result has the following fields:
| Field | Type | Description |
|---|---|---|
id | str | Memory record ID. |
content | str | The memory content. |
score | float | None | Similarity score. Higher values indicate stronger relevance. |
owner_id | str | None | Owner identifier. |
agent_id | str | None | Agent identifier. |
session_id | str | None | Session identifier. |
metadata | Dict | None | Additional metadata attached to the memory. |
created_at | str | None | Creation timestamp. |
Basic usage
- Hosted (lyzr-adk)
- Open Source (lyzr-cognis)
Filtered search
Narrow results by combining scope identifiers.Cross-session search
Search across all sessions for an owner by settingcross_session=True.
Limiting results
Async usage
"What is the user's favorite color?" retrieves more relevant results than a bare keyword like "favorite color".