From the course: Databases for Node.js Developers

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Performing text search in MongoDB

Performing text search in MongoDB - Node.js Tutorial

From the course: Databases for Node.js Developers

Performing text search in MongoDB

- [Instructor] In this video, we are making our shop page even more powerful by adding search functionality. And while we are at it, I will also show you how to sort items alphabetically. Currently, we can filter items by text. We saw this already. So I can click on baking so it will filter by baking. I can also clear the text, which will just load the page again. And what we already have is the search functionality. So I can, for instance, input schnitzel, but nothing will happen, but we see that there is now a query string up here in the browser. So the form is already there, but our route is right now doing nothing with it. In the previous video, we already created a text index for the item name and we will now utilize this index to do the search. And as I said, we also want to sort items alphabetically. And this is another use case now for the regular index that we have on the name field because it's also used for sorting. That said, sorting will always work, but when you have a…

Contents