INTRODUCTION
Welcome to our demonstration of Tacnode's full-text search capabilities. We'll be using the Tacnode Playground for this demonstration.
First, let's refresh our understanding of full-text search. Full-text search involves quickly searching for information within large volumes of unstructured text data. This is usually done by establishing an inverted index: we tokenize the text content, and map all the terms (words, phrases, and numbers) back to their respective documents where they were found. Full-text search is commonly used in search engines. For example, we often find ourselves searching for web page content on our search engine of choice. This usually means entering keywords into a search bar and getting a list of webpages that may be relevant to us. All of this is made possible with full-text search. In our BnB application, we will also need keyword-search functionality to find our ideal place to stay.
SCHEMA OVERVIEW
To do this, we've added a keys
field to the listings
table. This field stores all keyword information for each listing. Notice that the keys
field is of type tsvector
, which is a special data type that Tacnode uses to store keyword information.
To make our searches even faster, we've also created an inverted index on this field, which will greatly accelerate Tacnode's keyword-based query execution.
TACNODE PLAYGROUND
Next, let's begin our demonstration using the Tacnode Playground. Let's say we want to search for a listing in Chicago that features restaurants somehow. So, we can enter the keywords "Chicago" and "restaurant," then hit search. Almost instantly, we're able to see the listings that are relevant to our search.
So now, let's look at the details of one of these listings. We see that the name of the listing contains "Chicago," which was one of our keywords. If we scroll down to the reviews of the listing, we see that one of the reviews mentions "restaurants nearby," which was our second keyword.
So, how exactly was the query behind this search implemented? We used a tsquery
, which is a keyword-based query mechanism. Essentially, we converted our keywords into the tsquery
data type, with the function to_tsquery
, and then filtered this field as needed. This provides us with the desired result of listings that contain the keywords "Chicago" and "restaurant," using full-text search.
And with that, we conclude our demonstration of Tacnode's full-text search capabilities. Thank you for tuning in.