My 2 cents on the matter: this action would add [x] total shards, but this cluster currently has [x]/[x] maximum shards open;
When adding or searching data within an index, that index is in an open state, the longer you keep the indices open the more shards you use
- Each node can accommodate a number of shards, check how many shards a node can accommodate
"max_shards_per_node"
setting:
GET /_cluster/settings?include_defaults=true
Depending on the no of data nodes, you're going to have a max number of shards for your cluster, to check this just: GET _cluster/health
and check the active_shards
value (which represents the total number of active shards, including primary and replica shards).
Potential solutions to reduce the no of shards:
- Reduce the no of replicas (a redundant copy of the data) for index:
PUT /<index>/_settings
{
"index" : {
"number_of_replicas" : 0
}
}
# check index setting "number_of_replicas" afterward
GET <index>/_settings
- Close a specific index (once an index is closed, you cannot add data to it or search for any data within the index)
POST /<index>/_close
- Add another data node to the cluster.
Last but not least:
Shard size matters because it impacts both search latency and write performance, too many small shards will exhaust the memory (JVM Heap) too few large shards prevent OpenSearch from properly distributing requests, a good rule of thumb is to keep shard size between 10–50 GB.