Grokking MongoDB
0% completed
Searching Text with $regex and $text
A search for the word "reading" can return a document that does not contain "reading". The two queries below search the same six users, and the second one returns Zoë, whose description says "reads".
db.users.drop() db.users.insertMany([ { name: "Alice", description: "Alice loves reading and traveling." }, { name: "Bob", description: "Bob enjoys cycling and hiking." }, { name: "Charlie", description: "Charlie likes gaming and reading." }, { name: "David", description: "David prefers swimming and biking." },
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%