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

# Retrieve Chunks

> Search and retrieve relevant chunks from your documents

Search your documents and retrieve the most relevant chunks based on a natural language query.

> [tab] Python
>
> ```python theme={null}
> from morphik import Morphik
>
> db = Morphik("your-uri")
>
> chunks = db.retrieve_chunks(
>     query="What are the quarterly results?",
>     filters={"department": {"$eq": "sales"}},
>     k=5,
>     min_score=0.0,
>     use_colpali=True,
>     folder_name="/reports",
>     padding=1,
>     output_format="url"
> )
>
> for chunk in chunks:
>     print(f"Score: {chunk.score:.2f}")
>     print(f"Content: {chunk.content[:200]}...")
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import Morphik from 'morphik';
>
> // For Teams/Enterprise, use your dedicated host: https://companyname-api.morphik.ai
> const client = new Morphik({
>   apiKey: process.env.MORPHIK_API_KEY,
>   baseURL: 'https://api.morphik.ai'
> });
>
> const chunks = await client.retrieve.chunks.create({
>   query: 'What are the quarterly results?',
>   filters: { department: { $eq: 'sales' } },
>   k: 5,
>   min_score: 0.0,
>   use_colpali: true,
>   folder_name: '/reports',
>   padding: 1,
>   output_format: 'url'
> });
>
> chunks.forEach(chunk => {
>   console.log(`Score: ${chunk.score.toFixed(2)}`);
>   console.log(`Content: ${chunk.content.slice(0, 200)}...`);
> });
> ```

> [tab] cURL
>
> ```bash theme={null}
> curl -X POST "https://api.morphik.ai/retrieve/chunks" \
>   -H "Authorization: Bearer $MORPHIK_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "query": "What are the quarterly results?",
>     "filters": {"department": {"$eq": "sales"}},
>     "k": 5,
>     "min_score": 0.0,
>     "use_colpali": true,
>     "folder_name": "/reports",
>     "padding": 1,
>     "output_format": "url"
>   }'
> ```

For advanced filtering with operators like `$and`, `$or`, `$gte`, `$in`, see [Metadata Filtering](https://morphik.ai/docs/concepts/metadata-filtering.md).

## Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `query` | string | required | Natural language search query |
| `k` | int | `4` | Maximum number of chunks to return |
| `min_score` | float | `0.0` | Minimum similarity score threshold |
| `use_colpali` | boolean | `true` | Use Morphik multimodal embeddings (better for images/tables) |
| `filters` | object | `null` | Metadata filters (see [Metadata Filtering](https://morphik.ai/docs/concepts/metadata-filtering.md)) |
| `padding` | int | `0` | Extra pages to include before/after matches (multimodal only) |
| `output_format` | string | `"base64"` | Image format: `base64`, `url`, or `text` |

## Response

```json theme={null}
[
  {
    "document_id": "doc_abc123",
    "chunk_number": 3,
    "content": "Q4 revenue increased by 15% year-over-year...",
    "score": 0.89,
    "metadata": { "department": "sales" },
    "filename": "quarterly_report.pdf"
  }
]
```

> [!NOTE]
>
> Use `use_colpali=true` for documents with images, charts, or tables. Morphik multimodal embeddings provide significantly better retrieval accuracy for visual content.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.