Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Get Hyped: Synonyms in MongoDB Atlas Search

Sometimes, the word you’re looking for is on the tip of your tongue, but you can’t quite grasp it. For example, when you’re trying to find a really funny tweet you saw last night to show your friends. If you’re sitting there reading this and thinking, “Wow, Anaiya and Nic, you’re so right. I wish there was a fix for this,” strap on in! We have just the solution for those days when your precise linguistic abilities fail you, but you have an idea of what you’re looking for: Synonyms in Atlas Search.

In this tutorial, we are going to be showing you how to index a MongoDB collection to capture searches for words that mean similar things. For the specifics, we’re going to search through content written with Generation Z (Gen-Z) slang. The slang will be mapped to common words with synonyms and as a result, you’ll get a quick Gen-Z lesson without having to ever open TikTok.

If you’re in the mood to learn a few new words, alongside how effortlessly synonym mappings can be integrated into Atlas Search, this is the tutorial for you.

Read More

Influence Search Result Ranking with Function Scores in Atlas Search

When it comes to natural language searching, it’s useful to know how the order of the results for a query were determined. Exact matches might be obvious, but what about situations where not all the results were exact matches due to a fuzzy parameter, the $near operator, or something else?

This is where the document score becomes relevant.

Every document returned by a $search query in MongoDB Atlas Search is assigned a score based on relevance, and the documents included in a result set are returned in order from highest score to lowest.

You can choose to rely on the scoring that Atlas Search determines based on the query operators, or you can customize its behavior using function scoring and optimize it towards your needs. In this tutorial, we’re going to see how the function option in Atlas Search can be used to rank results in an example.

Read More

An Introduction to Indexes for MongoDB Atlas Search

Imagine reading a long book like “A Song of Fire and Ice,” “The Lord of the Rings,” or “Harry Potter.” Now imagine that there was a specific detail in one of those books that you needed to revisit. You wouldn’t want to search every page in those long books to find what you were looking for. Instead, you’d want to use some sort of book index to help you quickly locate what you were looking for. This same concept of indexing content within a book can be carried to MongoDB Atlas Search with search indexes.

Atlas Search makes it easy to build fast, relevant, full-text search on top of your data in the cloud. It’s fully integrated, fully managed, and available with every MongoDB Atlas cluster running MongoDB version 4.2 or higher.

Correctly defining your indexes is important because they are responsible for making sure that you’re receiving relevant results when using Atlas Search. There is no one-size-fits-all solution and different indexes will bring you different benefits.

In this tutorial, we’re going to get a gentle introduction to creating indexes that will be valuable for various full-text search use cases.

Read More

Searching on Your Location with Atlas Search and Geospatial Operators

When thinking about full-text search, text and other string data is probably the first thing to come to mind. In fact, if you’ve been keeping up with my tutorials, you might remember Building an Autocomplete Form Element with Atlas Search and JavaScript or Visually Showing Atlas Search Highlights with JavaScript and HTML, both of which were on text search examples in MongoDB Atlas Search.

Being able to use natural language search on text data is probably one of the most popular use-cases, but there are scenarios where you might need to narrow the results even further.

Let’s say you’re building a restaurant review application like Yelp or a bed and breakfast booking system like Airbnb. Sure, you’ll enter some kind of text criteria for what you’re looking for, but there’s also a location aspect to it. For example, if you want to find a place to get a cheeseburger within walking distance of your current location, you probably don’t want your search results to contain entries from another country. This is an example of a geo search, where you would want to return results based on location coordinates.

In this tutorial, we’re going to see how to use Atlas Search and the compound operator to search based on text entered and within a certain geographical area. For the text entered, we’ll use the autocomplete operator, and for the geospatial component, we’ll use the geoWithin operator.

Read More

Getting Started with the Realm SDK for Unity

Did you know that MongoDB has a Realm SDK for the Unity game development framework that makes working with game data effortless? The Realm SDK is currently an alpha release, but you can already start using it to build persistence into your cross platform gaming projects.

A few weeks ago I streamed about and wrote about creating an infinite runner type game using Unity and the Realm SDK for Unity. Realm was used for storing the score between scenes and sessions within the game.

There were a lot of deep topics in the infinite runner (think Temple Run or Subway Surfer) example, so I wanted to take a step back. In this tutorial, we’re going to spend less time making an interesting game and more time including and using Realm within a Unity project.

Read More

Build an Infinite Runner Game with Unity and the Realm Unity SDK

Did you know that MongoDB has a Realm SDK for the Unity game development framework that makes working with game data effortless? It’s currently an alpha release, but you can already start using it to build persistence into your cross platform gaming projects.

A popular game template for the past few years has been in infinite runner style games. Games such as Temple Run and Subway Surfers have had many competitors, each with their own spin on the subject. If you’re unfamiliar with the infinite runner concept, the idea is that you have a player that can move horizontally to fixed positions. As the game progresses, obstacles and rewards enter the scene. The player must dodge or obtain depending on the object and this happens until the player collides with an obstacle. As time progresses, the game generally speeds up to make things more difficult.

While the game might sound complicated, there’s actually a lot of repetition.

In this tutorial, we’ll look at how to create our own infinite runner game with Unity and C#. We’ll look at important concepts such as object pooling and collision, as well as data persistence using the Realm SDK for Unity.

Read More

Update Array Elements in a Document with MQL Positional Operators

MongoDB offers a rich query language that’s great for create, read, update, and delete operations as well as complex multi-stage aggregation pipelines. There are many ways to model your data within MongoDB and regardless of how it looks, the MongoDB Query Language (MQL) has you covered.

One of the lesser recognized but extremely valuable features of MQL is in the positional operators that you’d find in an update operation.

Let’s say that you have a document and inside that document, you have an array of objects. You need to update one or more of those objects in the array, but you don’t want to replace the array or append to it. This is where a positional operator might be valuable.

In this tutorial, we’re going to look at a few examples that would benefit from a positional operator within MongoDB.

Read More