Basic full-text search
Searching text will become something you do repeatedly when building applications or exploring data sets for data science. Full-text search is helpful when performing exploratory data analysis for a natural language processing model or building a search feature into your application.
In this exercise, you will practice searching a text column and match it against a string. The search will return the same result as a query that uses the LIKE
operator with the %
wildcard at the beginning and end of the string, but will perform much better and provide you with a foundation for more advanced full-text search queries. Let's dive in.
This exercise is part of the course
Functions for Manipulating Data in PostgreSQL
Exercise instructions
- Select the
title
anddescription
columns from thefilm
table. - Perform a full-text search on the
title
column for the wordelf
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Select the title and description
SELECT ___, ___
FROM film
-- Convert the title to a tsvector and match it against the tsquery
WHERE ____(___) ___ ___(___);