## Configure Replica Set Tag Sets 

Tag sets let you customize write concern and read preferences for a replica set . MongoDB stores tag sets in the replica set configuration object, which is the document returned by rs.conf() , in the members[n].tags embedded document. 

This section introduces the configuration of tag sets. For an overview on tag sets and their use, see Replica Set Write Concern (page 80) and Tag Sets (page 590). 

## Differences Between Read Preferences and Write Concerns 

Custom read preferences and write concerns evaluate tags sets in different ways: 

• Read preferences consider the value of a tag when selecting a member to read from. 

• Write concerns do not use the value of a tag to select a member except to consider whether or not the value is unique. 

For example, a tag set for a read operation may resemble the following document: 

{ "disk": "ssd", "use": "reporting" } 

To fulfill such a read operation, a member would need to have both of these tags. Any of the following tag sets would satisfy this requirement: 

{ "disk": "ssd", "use": "reporting" } { "disk": "ssd", "use": "reporting", "rack": "a" } { "disk": "ssd", "use": "reporting", "rack": "d" } { "disk": "ssd", "use": "reporting", "mem": "r"} 

The following tag sets would not be able to fulfill this query: 

{ "disk": "ssd" } { "use": "reporting" } { "disk": "ssd", "use": "production" } { "disk": "ssd", "use": "production", "rack": "k" } { "disk": "spinning", "use": "reporting", "mem": "32" } 

## Add Tag Sets to a Replica Set 

Given the following replica set configuration: 

{ "_id" : "rs0", "version" : 1, "members" : [ { "_id" : 0, "host" : "mongodb0.example.net:27017" }, { "_id" : 1, "host" : "mongodb1.example.net:27017" }, { "_id" : 2, "host" : "mongodb2.example.net:27017" 

