﻿---
title: Shard near document limit
description: Describes what AutoOps detects and surfaces with the Shard near document limit 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/shard_near_document_limit
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
---

# Shard near document limit
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 have shards approaching the maximum document count.
The shard with the most documents is on logs-prod-000045 (42 GB documents).
Other affected indices: `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 42 GB) 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 for time-series indices approaching document limit.If logs-prod-000045 are time-based, roll them over and set 1 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 42 GB documents.
</dropdown>


#### Background and impact

Shards in 12 are approaching the maximum recommended document count for a single shard (200,000,000).
This can happen when parent/child or nested documents route child docs to the same shard as the parent. It can also happen when an index has too few primary shards, or when time-series indices are not rolled over before they grow too large.
If a shard reaches the limit, indexing to that shard can fail until you split, reindex, or roll over.

## Guide

[Size your shards](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/deploy-manage/production-guidance/optimize-performance/size-shards)