Monday, 30 November, 2020 UTC


Summary

When it comes to finding specific words or phrases within text, you’re probably going to want to use a natural language search option like full-text search (FTS). Sure, you could probably create a complicated and difficult-to-maintain set of regular expressions to search within text, but that is an option that most developers don’t want. Not to mention it won’t cover the full scope of what a natural language processor typically accomplishes.
In a previous tutorial titled Building an Autocomplete Form Element with Atlas Search and JavaScript, I wrote about searching for recipes, as they are being typed, in MongoDB Atlas using the autocomplete operator. While this tutorial accomplished the job quite well, it didn’t elaborate on what exactly was being matched for any given term.
In this tutorial, we’re going to see how to use Atlas Search and work with the highlight data to visually show any matches on the terms in a user facing application. Highlighting is a powerful tool with Search to allow your users to find the exact text that they want in its proper context.
The post Visually Showing Atlas Search Highlights with JavaScript and HTML appeared first on MongoDB.