> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# search • AI Agent SDK

> search: Search memories in MongoDB.

# search

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**MongoDBMemory**](../classes/MongoDBMemory) class in the [**knowledge**](../modules/knowledge) module.

Search memories in MongoDB.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def search(query: Any, user_id: Any, agent_id: Any, run_id: Any, rerank: Any) -> Any
```

## Parameters

<ParamField query="query" type="Any" required={true}>
  No description available.
</ParamField>

<ParamField query="user_id" type="Any" required={false}>
  No description available.
</ParamField>

<ParamField query="agent_id" type="Any" required={false}>
  No description available.
</ParamField>

<ParamField query="run_id" type="Any" required={false}>
  No description available.
</ParamField>

<ParamField query="rerank" type="Any" required={false} default="False">
  No description available.
</ParamField>

### Returns

<ResponseField name="Returns" type="Any">
  The result of the operation.
</ResponseField>

## Uses

* `aggregate`
* `limit`
* `find`
* `logging.error`

## Used By

* [`process_task_context`](../functions/process_task_context)
* [`Knowledge.search`](../functions/Knowledge-search)
* [`Memory.search_short_term`](../functions/Memory-search_short_term)
* [`Memory.search_long_term`](../functions/Memory-search_long_term)
* [`Memory.search_user_memory`](../functions/Memory-search_user_memory)

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/knowledge/knowledge.py#L210">
  `praisonaiagents/knowledge/knowledge.py` at line 210
</Card>
