sh.removeTagRange()

Definition

  • sh.removeTagRange(namespace, minimum, maximum, tag)

Changed in version 3.4: This method aliases to sh.removeRangeFromZone() in MongoDB 3.4. The functionality specifiedbelow still applies to MongoDB 3.2. MongoDB 3.4 provides Zone sharding as the successor to tag-aware sharding.

New in version 3.0.

Removes a range of shard key values to a shard tag created using thesh.addShardTag() method. sh.removeTagRange() takesthe following arguments:

ParameterTypeDescriptionnamespacestringThe namespace of the sharded collection to tag.minimumdocumentThe minimum value of the shard key from the tag. Specifythe minimum value in the form of <fieldname>:<value>. Thisvalue must be of the same BSON type or types as the shard key.maximumdocumentThe maximum value of the shard key range from the tag.Specify the maximum value in the form of <fieldname>:<value>. Thisvalue must be of the same BSON type or types as the shard key.tagstringThe name of the tag attached to the range specified by the minimumand maximum arguments to.

Use sh.removeShardTag() to ensure that unused or out ofdate ranges are removed and hence chunks are balanced as required.

Only issue sh.removeTagRange() when connected to amongos instance.

Example

Given a shard key of {state: 1, zip: 1}, the following operationremoves an existing tag range covering zip codes in New York State:

  1. sh.removeTagRange( "exampledb.collection",
  2. { state: "NY", zip: MinKey },
  3. { state: "NY", zip: MaxKey },
  4. "NY"
  5. )