How to shrink an index spread over multiple nodes

Hey Team,

How do i go about shrinking an index, which has shards over multiple nodes ?
I keep getting this error

  "error": {
    "root_cause": [
        "type": "remote_transport_exception",
        "reason": "[pronto-g3-1577817661-3-1463179-pronto][][indices:admin/resize]"
    "type": "illegal_state_exception",
    "reason": "index time_logs_data_2020_06_16 must have all shards allocated on the same node to shrink index"
  "status": 500

I would also like to explore if there's any way of enforcing future indices to be created on the same node, so i can shrink them later on when they become read only. Thanks in advance!

Before you can shrink an index:

  • The index must be read-only.
  • A copy of every shard in the index must reside on the same node.
  • The cluster health status must be green.

Check out this part of ILM.

Wonder why cluster has to be green ... makes sense for index to be green, I guess - though what about replicas? Ah, says the node only needs a copy of each shard, not all the shards (can be some replicas, though hard to do that in practice).

Note that doc is really not right as says the API call "three conditions can be achieved" - but one condition is green cluster; pretty sure no API call can make a cluster green :wink:

You'd normally drop the replica set before reallocating the shards, shrinking, then add them back.

Makes sense; surprised not mentioned in that somewhat confusing doc page.

I would encourage you to raise a docs issue on GitHub to get it added if you'd like to see it there.

1 Like

Thanks - is there a link/dock on best way to do that; seen the awesome Github doc repo, but not sure how to raise issue on specific page (vs. the 'project').

The docs are part of each product, so raise a feature request -

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.