[MongoDB] : DBQuery.Option.partial
If a shard is inaccessible or unavailable, queries will return with an error. However, a client may set the partial query bit, which will then return results from all available shards, regardless of whether a given shard is unavailable.
The exact method for distributing queries to shards in a cluster depends on the nature of the query and the configuration of the sharded cluster.
http://docs.mongodb.org/manual/reference/method/cursor.addOption/#DBQuery.Option.partial
|
Sets the cursor to return partial data from a query against a sharded cluster in which some shards do not respond rather than throwing an error |
mongos> db.shrcol.find({ “user_id” : { $gte : 4858 , $lte : 143853 }}).addOption(DBQuery.Option.partial)
{ “_id” : ObjectId(“553a1271abd490759305348c”), “user_id” : 4858, “iteration#” : 4858, “company” : “citi”, “data” : “dummy data”, “occurance” : 4858 }
{ “_id” : ObjectId(“553a1271abd490759305348d”), “user_id” : 4859, “iteration#” : 4859, “company” : “citi”, “data” : “dummy data”, “occurance” : 4859 }
{ “_id” : ObjectId(“553a1271abd490759305348e”), “user_id” : 4860, “iteration#” : 4860, “company” : “citi”, “data” : “dummy data”, “occurance” : 4860 }
{ “_id” : ObjectId(“553a1271abd490759305348f”), “user_id” : 4861, “iteration#” : 4861, “company” : “citi”, “data” : “dummy data”, “occurance” : 4861 }
{ “_id” : ObjectId(“553a1271abd4907593053490”), “user_id” : 4862, “iteration#” : 4862, “company” : “citi”, “data” : “dummy data”, “occurance” : 4862 }
{ “_id” : ObjectId(“553a1271abd4907593053491”), “user_id” : 4863, “iteration#” : 4863, “company” : “citi”, “data” : “dummy data”, “occurance” : 4863 }
{ “_id” : ObjectId(“553a1271abd4907593053492”), “user_id” : 4864, “iteration#” : 4864, “company” : “citi”, “data” : “dummy data”, “occurance” : 4864 }
{ “_id” : ObjectId(“553a1271abd4907593053493”), “user_id” : 4865, “iteration#” : 4865, “company” : “citi”, “data” : “dummy data”, “occurance” : 4865 }
{ “_id” : ObjectId(“553a1271abd4907593053494”), “user_id” : 4866, “iteration#” : 4866, “company” : “citi”, “data” : “dummy data”, “occurance” : 4866 }
{ “_id” : ObjectId(“553a1271abd4907593053495”), “user_id” : 4867, “iteration#” : 4867, “company” : “citi”, “data” : “dummy data”, “occurance” : 4867 }
{ “_id” : ObjectId(“553a1271abd4907593053496”), “user_id” : 4868, “iteration#” : 4868, “company” : “citi”, “data” : “dummy data”, “occurance” : 4868 }
{ “_id” : ObjectId(“553a1271abd4907593053497”), “user_id” : 4869, “iteration#” : 4869, “company” : “citi”, “data” : “dummy data”, “occurance” : 4869 }
{ “_id” : ObjectId(“553a1271abd4907593053498”), “user_id” : 4870, “iteration#” : 4870, “company” : “citi”, “data” : “dummy data”, “occurance” : 4870 }
{ “_id” : ObjectId(“553a1271abd4907593053499”), “user_id” : 4871, “iteration#” : 4871, “company” : “citi”, “data” : “dummy data”, “occurance” : 4871 }
{ “_id” : ObjectId(“553a1271abd490759305349a”), “user_id” : 4872, “iteration#” : 4872, “company” : “citi”, “data” : “dummy data”, “occurance” : 4872 }
{ “_id” : ObjectId(“553a1271abd490759305349b”), “user_id” : 4873, “iteration#” : 4873, “company” : “citi”, “data” : “dummy data”, “occurance” : 4873 }
{ “_id” : ObjectId(“553a1271abd490759305349c”), “user_id” : 4874, “iteration#” : 4874, “company” : “citi”, “data” : “dummy data”, “occurance” : 4874 }
{ “_id” : ObjectId(“553a1271abd490759305349d”), “user_id” : 4875, “iteration#” : 4875, “company” : “citi”, “data” : “dummy data”, “occurance” : 4875 }
{ “_id” : ObjectId(“553a1271abd490759305349e”), “user_id” : 4876, “iteration#” : 4876, “company” : “citi”, “data” : “dummy data”, “occurance” : 4876 }
{ “_id” : ObjectId(“553a1271abd490759305349f”), “user_id” : 4877, “iteration#” : 4877, “company” : “citi”, “data” : “dummy data”, “occurance” : 4877 }
Type “it” for more
mongos>
mongos>
mongos> db.shrcol.find({ “user_id” : { $gte : 4858 , $lte : 143853 }})
error: {
“$err” : “socket exception [CONNECT_ERROR] for rs3/12d4-dl585-04:27030,12d4-dl585-04:27031”,
“code” : 11002,
“shard” : “rs3”
}
mongos>
mongos>