
Sign up to save your podcasts
Or


When working with large databases it is often accusatory to want to be able to find specific keywords in this database. Over the next few minutes I will be explaining how to create search indexes in MongoDB. Creating a search engine in MongoDB allows for one to be able to text search with Mongoose. This will be done using Nodejs and Expressjs.
First one wants to create a search index with the MongDB Shell. To do this one wants to type in the following command with the MongoDB Shell. Note this command is straight from the MongoDB Docs that can be found in the references section.
db.tasks.createIndex({ task: “text” }); (Mongodb, n.d.)
This command creates an index on the tasks collection and allows for the next link of code which will search the tasks collection for the task item.
db.tasks.find({ $text: { $search: “learn Angular” }})
This line of code searches the tasks collection for the task item for the term “learn Angular”. From there the data can be displayed and allows for one to display the data on the front-end.
Feel free to subscribe! Happy adventures in code!
Reference
MongoDB. (n.d.). Text Search. Retrieved from https://docs.mongodb.com/manual/text-search/.
By Javascript NewsWhen working with large databases it is often accusatory to want to be able to find specific keywords in this database. Over the next few minutes I will be explaining how to create search indexes in MongoDB. Creating a search engine in MongoDB allows for one to be able to text search with Mongoose. This will be done using Nodejs and Expressjs.
First one wants to create a search index with the MongDB Shell. To do this one wants to type in the following command with the MongoDB Shell. Note this command is straight from the MongoDB Docs that can be found in the references section.
db.tasks.createIndex({ task: “text” }); (Mongodb, n.d.)
This command creates an index on the tasks collection and allows for the next link of code which will search the tasks collection for the task item.
db.tasks.find({ $text: { $search: “learn Angular” }})
This line of code searches the tasks collection for the task item for the term “learn Angular”. From there the data can be displayed and allows for one to display the data on the front-end.
Feel free to subscribe! Happy adventures in code!
Reference
MongoDB. (n.d.). Text Search. Retrieved from https://docs.mongodb.com/manual/text-search/.