Home / C100DBA / Practice questions Question 21
Which two statements are true about the Java driver? (Choose two.) The driver uses JMX to allow for monitoring. The driver’s first authentication mechanism preference is PLAIN. The driver can be setup via Maven or Gradle. The driver automatically sets Read Preference to “primaryPreferred”. Question 22
A collection has the following documents:{_id: 1, lastName: “Doe”, hobbies: “likes sports, reading, and bird watching“}{_id: 2, lastName: “Spears”, hobbies: “likes to ride a bike and hiking“}{_id: 3, lastName: “Smith”, hobbies: “likes to watch movies and medieval spears“}A text search query follow the pattern “find all people where ‘spears’ appears in any data field”. The appropriate analyzer has been selected to support this query.What Atlas Search index should be created? { “mappings”: {“dynamic”: yes}} { “mappings”: {“dynamic”: true}} { “mappings”: {“dynamic”: 1}} { “mappings”: {“dynamic”: “runtime}} Question 23
Given the following sample documents in the inventory collection:{ _id: 6305, name: “A. S.”, “assignment” : 5, “status” : “A” },{ _id: 6308, name: “B. M.”, “assignment” : 3, “status” : “B” },{ _id: 6312, name: “E. M.”, “assignment” : 5, “status” : “C” },{ _id: 6319, name: “R. S.”, “assignment” : 2, “status” : “D” },{ _id: 6322, name: “A. S.”, “assignment” : 2, “status” : “A” },{ _id: 6234, name: “R. S.”, “assignment” : 1, “status” : “B” },{ _id: 6235, name: “A. S.”, “assignment” : 1, “status” : “C” },{ _id: 6315, name: “E. M.”, “assignment” : 3, “status” : “A” },What expression will remove only one document with “status”: ”A” in the inventory collection? db.inventory.deleteMany ({“status”: “A”}) db.inventory.deleteOne ({“status”: “A”}) db.inventory.insertOne ({“status”: “A”}) db.inventory.remove ({“status”: “A”}) Question 24
What syntax connects to a MongoDB Atlas cluster via the Java Driver using the DNS seed list connection format? ConnectionString connectionString = new ConnectionString(“mongodb+srv://_mongodb._tcp.cluster0.myorg.mongodb.net/test?retryWrites=true&w=majority”); ConnectionString connectionString = new ConnectionString(“mongodb://_mongodb._tcp.cluster0.myorg.mongodb.net/test?retryWrites=true&w=majority”); ConnectionString connectionString = new ConnectionString(“mongodb+srv://cluster0.myorg.mongodb.net/test?retryWrites=true&w=majority”); ConnectionString connectionString = new ConnectionString(“mongodb://cluster0.myorg.mongodb.net/test?retryWrites=true&w=majority”); Question 25
Given the following sample documents in the incidents collection:{ _id: 232, ts: ISODate(“2022-05-20T12:02:00Z”), component: “ABC”, status: “Closed” },{ _id: 153, ts: ISODate(“2022-05-22T10:20:00Z”), component: “ABC”, status: “In Progress” },{ _id: 353, ts: ISODate(“2022-05-24T22:09:00Z”), component: “XYZ”, status: “Opened” },{ _id: 464, ts: ISODate(“2022-05-24T09:12:00Z”), component: “XYZ”, status: “Opened” },{ _id: 212, ts: ISODate(“2022-05-24T12:23:00Z”), component: “XYZ”, status: “Closed” },{ _id: 484, ts: ISODate(“2022-05-24T20:46:00Z”), component: “ABC”, status: “In Progress” },What command updates only the earliest opened incident, changes its status to “In Progress”, and returns the original document? db.incidents.updateOne({ “status” : “Opened” }, { $set : { status : “ In Progress” } }, { sort : { “ts” : 1 } }) db.incidents.updateOne({ “status” : “Opened” }, { $set : { status : “ In Progress” } }, { sort : { “ts” : -1 } }) db.incidents.findOneAndUpdate({ “status” : “Opened” }, { $set : { status : “ In Progress” } }, { sort : { “ts” : 1 } }) db.incidents. findOneAndUpdate({ “status” : “Opened” }, { $set : { status : “ In Progress” } }, { sort : { “ts” : -1 } })