Join the discussion
Question 1/88
You have the following index in a movies collection: { "title": 1, "imdb.rating": -1, "imdb.votes": -1, "type": 1 } Can the following query use the given index for both filtering and sorting?
db.movies.find( { "title": { "$lt": "M" } } ).sort( { "imdb.votes": -1 } )
db.movies.find( { "title": { "$lt": "M" } } ).sort( { "imdb.votes": -1 } )
Correct Answer: B
No, this query does not use equality in the index prefix. When you use an index to filter and sort, the query must contain equality conditions on all prefix keys that precede the sort keys. Also, it skipped the next key in the "imdb.rating" prefix in the sort predicate. https://docs.mongodb.com/manual/indexes/
Add Comments
- Other Question (88q)
- Q1. You have the following index in a movies collection: { "title": 1, "imdb.rating": -1, "imd...
- Q2. The $sortByCount stage is equivalent to:
- Q3. We can use this pattern to work with different schema versions. It mainly involves adding ...
- Q4. In which situations can we consider sharding?
- Q5. Let's consider a one-to-many relationship observed between an instructor and the courses h...
- Q6. Suppose you have a sales collection with the following document structure: { _id: ObjectId...
- Q7. You have the following index in a movies collection: { "title": 1, "imdb.rating": -1, "imd...
- Q8. Suppose you added the following index to a products collection: { product_category: 1 } Wh...
- Q9. We have the following index in a movies collection: { title: 1, genres: 1 } We want to ins...
- Q10. The users collection in the database is given. Which field will be the best candidate for ...
- Q11. Which cursor method should you use to specify the maximum number of documents returned?...
- Q12. Select all true statements about query plans in MongoDB. (select 2)...
- Q13. Given a movies collection where each document has the following structure: { _id: ObjectId...
- Q14. Suppose you have a sales collection with the following document structure: { _id: ObjectId...
- Q15. Suppose you have a developers collection with the following document structure: { _id: 1, ...
- Q16. You have to create a simple configuration file for mongod instance. Here are the requireme...
- Q17. Select read concern levels that are supported by transactions in MongoDB....
- Q18. We have an accounts collection with the following document structure: { _id: ObjectId("5ca...
- Q19. How to connect to MongoDB with mongod to localhost running on port 27017?...
- Q20. What can you deduce from the explain() method? For example: db.collection.find().explain()...
- Q21. Select all true statements about one-to-zillions relationships (a special case of the one-...
- Q22. It's very important to picking a good shard key. If we don't choose a good shard key, then...
- Q23. Given a flights collection that is sharded on the following shard key: { "airline_id" : 1,...
- Q24. Given a movies collection where each document has the following structure: { _id: ObjectId...
- Q25. Suppose you have a reviews collection in your database and you want to optimize the follow...
- Q26. Select true statements about capped collections....
- Q27. Given a companies collection where each document has the following structure: { _id: Objec...
- Q28. There is a collection named products in MongoDB database. Your coworker wants to know how ...
- Q29. What is MongoDB Charts?
- Q30. Suppose you want to familiarize with a new collection and want to display a single documen...
- Q31. A collection called players contains the following documents: [ { _id: 1, user: 'Tom', sco...
- Q32. Which cursor method should you use to force MongoDB to use a specific index for a query?...
- Q33. Use case: e-learning platform Which of the following scenarios is the best candidate to us...
- Q34. Suppose you have a developers collection with only two documents: { _id: 1, lname: 'Smith'...
- Q35. Select all true statements about MongoDB documents....
- Q36. There are some special databases in MongoDB that we cannot use to create a new database. S...
- Q37. What stages will cause a merge on the primary shard for a database?...
- Q38. Suppose you have a mobile_games collection with the following document structure: { game: ...
- Q39. You have the following configuration file: storage: dbPath: /var/mongodb/db net: bindIp: l...
- Q40. Select all true statements about chunks in MongoDB....
- Q41. Suppose you have a companies collection in your database. Only the following documents are...
- Q42. Select all true statements about data modeling in MongoDB....
- Q43. Consider the following command: $ mongod --dbpath /data/db --logpath /data/logs --replSet ...
- Q44. Suppose you have the following index on a routes collection: db.routes.createIndex( { airp...
- Q45. Select true statements about data modeling in MongoDB....
- Q46. You have to launch a replica set with three members. For the first node you have the follo...
- Q47. Suppose you have a companies collection in your database. Only the following documents are...
- Q48. How to create a new user with the root role named root_user with password root123?...
- Q49. Which of the following built-in roles provides the greatest cluster management access?...
- Q50. Let's consider a replica set of 3 nodes that experiences a network outage. Select true sta...
- Q51. Suppose you insert the following documents into companies collection: db.companies.insertM...
- Q52. A collection called players contains the following documents: [ { _id: 1, user: 'Tom', sco...
- Q53. Which of the following commands are valid to start a mongod?...
- Q54. Which cursor method should you use to get information about the query plan?...
- Q55. How many indexes will the following command create? db.products.createIndex( { product_nam...
- Q56. Select all default configurations for mongod.
- Q57. Can arrays in MongoDB store values of different data types?...
- Q58. What does it command do in the mongo shell?
- Q59. Select all true statements regarding to the _id field in MongoDB documents. (select 4)...
- Q60. Which cursor method should you use to return the number of documents in the result set?...
- Q61. Why is high cardinality important when choosing a shard key?...
- Q62. We have a movies collection with the following document structure: { _id: ObjectId("573a13...
- Q63. Assign typical operational tasks to the Database Administrator....
- Q64. We have a movies collection with the following document structure: { _id: ObjectId("573a13...
- Q65. You are working in a team on a certain application in the gaming sector. Queries similar t...
- Q66. Which of the following actions are granted to the built-in read role?...
- Q67. Select all true statements about reconfiguring a replica set with rs.reconfig()....
- Q68. Select all true statements about the $merge stage....
- Q69. In your database there is a collection named trips with the following document structure: ...
- Q70. Data modeling. You are considering the use of nesting or the references in your data model...
- Q71. We have the following schema for a movies collection: { _id: ObjectId, title: String, genr...
- Q72. Select all true statements about differences between using aggregate() and find() methods?...
- Q73. Which of the following scenarios best suits the use of the Tree Pattern?...
- Q74. Which of the following methods executes a database command? (mongo shell)...
- Q75. Data modeling. You are considering the use of nesting or references in your data model. Yo...
- Q76. Given a movies collection where each document has the following structure: { _id: ObjectId...
- Q77. Suppose you want to join two collections in the same database. What aggregation stage do y...
- Q78. We have the following indexes in a movies collection: { _id: 1 } { title: 1, year: 1 } Whi...
- Q79. Select all true statements regarding to unique indexes in MongoDB....
- Q80. Select the method that forces MongoDB to use a specific index....
- Q81. Suppose you have a companies collection in your database. Only the following documents are...
- Q82. Use case: e-learning platform Which of the following scenarios is the best candidate to us...
- Q83. We have a movies collection with the following document structure: { _id: ObjectId("573a13...
- Q84. Why is MongoDB a NoSQL database?
- Q85. Select all true statements regarding to the role of fields and values in a MongoDB documen...
- Q86. We have a movies collection with the following document structure: { _id: ObjectId("573a13...
- Q87. Which command do you use to display all indexes in routes collection?...
- Q88. Given the following example document from an artists collection: { _id: 5, last_name: 'Mau...
