In this short post, I will discuss searching on a website and how to create a search function. Initially, “search” always refers to text search. This feature has been around for a long time and does not require any additional work; you just need to connect this function to your project. But users are not always willing to type letters to find something; it is much easier to click on a ready-made button and get the result. Tags can provide this functionality.
In order for the tagging system to start working, several issues need to be resolved:
Create a tag search function
Assign tags to each video
Decide whether a unified tagging system is needed
Let's examine each point separately.
Creating a tag search function. It's actually not as difficult as it might seem at first glance. From a technical standpoint, tags are an array of strings. Each record in the database (each video) has such an array. We just need to find the records in the database where this array contains the maximum number of matching strings, and then sort the results. In MongoDB, this can be done using the aggregation function. I am deliberately not going into technical details so that the article is interesting to read even for people who are not involved in writing code.
Assigning tags to each video. Initially, I used AI to create tags for videos, but later I abandoned this approach. Why? At first glance, it seems that you don't need to do anything and AI will do the job perfectly. I thought so too, but when I prepared 50 test videos with tags, I realized that AI can use different word variations for the same topic. For example, in some cases, AI may generate the tag “slow motion experiment,” and in other cases, simply “slow motion.” Although these two tags have a common meaning, technically they are two different tags because the search is based on an exact string match. The more such discrepancies there are, the less accurate the search becomes. And this brings us to the third problem.
Is a unified tagging system necessary? It turns out that it is. Without a unified system, AI is not always able to generate the same tags, or perhaps I simply do not know how to explain this to AI. As a result, I decided to create my own tagging system. The system includes the video topic and tags that I came up with for this topic myself, i.e., the system contains only the main topics, which allows you to simply copy ready-made tags when creating a video “card,” but still need to add more detailed information for each one yourself.
This is how I implemented tag search on my site. Maybe you know an easier way or a completely different approach? Share your opinion in the comments.
This post is part of my “Building Smash World” series, where I share my observations about creating the platform.
If you want to see how it works in action, you can try it on smashworld.fun