> For the complete documentation index, see [llms.txt](https://docs.envector.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.envector.io/1.5.x/sdk-user-guide/encrypted-index/partitions.md).

# Partitions

A collection (index) can be subdivided into named **partitions**: inserts target a partition, and searches can be scoped to a subset of partitions — for **data isolation** and **query pruning**. Non-partitioned indexes are fully backward compatible.

Every index is created with a reserved **`_default`** partition. Inserts and searches that don't name a partition use `_default`. **Each item belongs to exactly one partition.** All partitions of a collection share the parent's schema (`key_id`, `dim`, `index_type`), encryption key, and — for IVF — trained centroids, while their data stays physically separate.

## Managing partitions

```python
import pyenvector as ev

# A collection starts with the _default partition.
index = ev.create_index("docs", dim=128)
ev.list_partitions("docs")     # [{'name': '_default', 'status': 'active', 'num_vectors': 0}]

# Create a named partition (must not be "_default" and must not already exist).
ev.create_partition("docs", "prod")
ev.list_partitions("docs")     # _default, prod

# Drop a partition and all of its data ("_default" cannot be dropped).
ev.drop_partition("docs", "prod")
```

| Method                                         | Description                                                                                   |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `create_partition(index_name, partition_name)` | Create a named partition. `partition_name` must not be `_default` and must not already exist. |
| `list_partitions(index_name)`                  | Return the collection's partitions as dicts `{name, status, num_vectors}`.                    |
| `drop_partition(index_name, partition_name)`   | Drop a partition and remove its data. `_default` cannot be dropped.                           |

## Routing inserts into a partition

Pass `partition_name` to [`insert`](/1.5.x/sdk-user-guide/insert.md) to route data into a specific partition. When omitted, data goes to `_default`.

```python
import numpy as np
vecs = np.random.uniform(-1, 1, (100, 128))

index.insert(vecs, metadata=[...])                        # -> _default
index.insert(vecs, metadata=[...], partition_name="prod") # -> prod
```

## Scoping a search to partitions

Pass `partition_names` (a list) to [`search`](/1.5.x/sdk-user-guide/search.md) to restrict a query to those partitions. When omitted, the search runs over `_default`.

```python
# Search a single partition (results + metadata come only from it).
hits = index.search(vecs[0], top_k=5, output_fields=["metadata"], partition_names=["prod"])

# Search across several partitions — merged top-k by score.
hits = index.search(vecs[0], top_k=10, output_fields=["metadata"], partition_names=["prod", "_default"])
```

> A multi-partition search runs one search per partition and merges the per-partition top-k on the client by score. Since each item belongs to exactly one partition, the merge has no cross-partition duplicates.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.envector.io/1.5.x/sdk-user-guide/encrypted-index/partitions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
