FIT3176 W4 Lab 03 Activity Sheet 3 MongoDB Text Search
FIT3176 W4 Lab 03 Activity Sheet 3 MongoDB Text Search
Text Search
1. Find the students who are using Gmail.
Can you find it without knowing the full email address?
db.students.createIndex({emailAddress: "text"})
Can you find the students who are using Gmail now?
4. Show students who are off-campus students and using Gmail. Sort the result by the email
address in ascending order.
2
5. Open MongoDB Compass, then connect to localhost. In the list of databases, you will
have the studentEnrolment. Select the studentEnrolment database.
6. Currently, you only have the students collection in this database. Select the
students collection and observe the documents inside this collection, including their
data type.
7. Go to the Indexes tab. How many indexes are there? Write down your observations.
8. Go to the Explain Plan tab and type in {$text: {$search: "gmail"}} in the
Filter field. Have a look at the Query Performance Summary.
The End