﻿---
title: Max Documents Per Shard
description: Describes what AutoOps detects and surfaces with the Max Documents Per Shard insight: One or more shards are approaching the practical maximum document count per shard (about 200 million documents).
url: https://docs-v3-preview.elastic.dev/elastic/autoops-insights/tree/main/elasticsearch/max_documents_per_shard
products:
  - Elastic Cloud Enterprise
  - Elastic Cloud Hosted
  - Elastic Cloud on Kubernetes
  - Elasticsearch
applies_to:
  - Elastic Cloud Hosted: Generally available
  - Elastic Cloud on Kubernetes: Generally available
  - Elastic Cloud Enterprise: Generally available
  - Self-managed Elastic deployments: Generally available
---

# Max Documents Per Shard
One or more shards are approaching the practical maximum document count per shard (about 200 million documents). Uneven growth can come from parent/child or nested routing, too few primary shards, or missing rollover for time-series indices.
<note>
  For a complete list of insights, refer to [AutoOps insights](https://docs-v3-preview.elastic.dev/elastic/autoops-insights/tree/main/elasticsearch).
</note>


## Insight details


| Field     | Value                          |
|-----------|--------------------------------|
| Component | Elasticsearch                  |
| Severity  | High                           |
| Scope     | Index                          |
| Domains   | disk-storage, index-management |


## Customization settings

You can customize these settings to adjust when AutoOps detects this event and presents the insight. Refer to [AutoOps event settings](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/deploy-manage/monitor/autoops/ec-autoops-event-settings) for details.
The default customization settings are:

| Setting                               | Type            | Default |
|---------------------------------------|-----------------|---------|
| Exclude indices based on this pattern | List of strings |         |


## Example: What you might see in AutoOps

The following is an example of what you might see when this insight is triggered. Real insights use live data and links from your deployment or cluster.

### One or more shards are approaching the max document limit


#### What was detected

More than 25 indices with shards approaching the maximum number of documents were found. The index that contains the most documents in a single shard is logs-prod-000045 with 42,000,000 documents. Other sampled indices approaching the maximum document limit: `logs-prod-000045`, `logs-prod-000046`.

#### Recommendations

<note>
  AutoOps shows different recommendations depending on how their conditions match your deployment or cluster.
</note>

<dropdown title="Split index into more shards">
  **Condition**: Shown when primary shard count is less than data node count.Use the Split API to split logs-prod-000045 (current size logs-prod-000045) into 2 primary shards with the action below. Run during low cluster load and confirm you have enough disk space. See the [Split index API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-split) for prerequisites.
  ```json

  {
    "settings": {
      "index.number_of_shards": 2
    }
  }
  ```

  <note>
    Requires the `manage cluster` privilege. Requires Elasticsearch 8.0.0 or later. This action changes cluster or index configuration.
  </note>
</dropdown>

<dropdown title="Rollover indices">
  **Condition**: Shown when for time-series indices approaching document limit.If logs-prod-000045 are time-based, roll them over and set 2 primary shards on the new write index so you can avoid a heavy segment merge on the current indices.
</dropdown>

<dropdown title="Reindex into smaller indices">
  **Condition**: Shown when primary shard count is less than data node count.Reindex into smaller indices to reduce shard sizes and improve search performance.
</dropdown>

<dropdown title="Split index into more shards">
  **Condition**: Shown when shard document count approaches limit and split is viable.Use the [Split API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-split) to split logs-prod-000045 into a new index with more primary shards. Its largest shard currently holds 0 documents.
</dropdown>


#### Background and impact

Shards in indexes 12 are approaching the maximum recommended number of documents allowed for a single shard (200,000,000). This can happen in unbalanced scenarios with parent/child relationships and nested documents, as child documents are routed to the same shard as the parent document. For all other cases, this can happen because the index does not have enough shards or, for time series data, the index needs to be rolled over.