MongoDB Aggregation & Indexing Quiz (original) (raw)
What is the purpose of the MongoDB aggregation framework?
- To modify existing documents
- To perform complex data transformations and analysis
- To store multiple collections in a database
- To enforce schema validation
Which aggregation stage is used to group documents based on a specific field?
What does the $lookup stage do in MongoDB aggregation?
- Retrieves documents from another collection
- Sorts documents in ascending or descending order
- Filters documents based on conditions
- Removes duplicate documents from the result
Which aggregation stage is used to filter documents before processing?
What is the primary purpose of the $out stage in MongoDB aggregation?
- Outputs results as a new collection
- Displays results in a formatted way
- Exports aggregation results to a JSON file
- Removes specific fields from the output
What is the main advantage of using indexes in MongoDB?
- Improve query performance
- Prevent duplicate records
How do you create an index on a single field in MongoDB?
- db.collection.addIndex({ field: 1 })
- db.collection.createIndex({ field: 1 })
- db.collection.index({ field: 1 })
- db.collection.ensureIndex({ field: 1 })
Which type of index is used to search text in MongoDB?
What happens when you drop an index in MongoDB?
- The index is permanently removed
- The collection is deleted
- MongoDB rolls back to an older state
- Queries become more efficient
What is the purpose of a compound index in MongoDB?
- To store multiple indexes in one collection
- To allow indexing on multiple fields
- To create a separate collection for indexed fields
- To convert numeric fields into indexed strings
There are 10 questions to complete.
Take a part in the ongoing discussion