0
0
PostgreSQLquery~10 mins

Highlighting with ts_headline in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to highlight the word 'database' in the text using ts_headline.

PostgreSQL
SELECT ts_headline('english', 'This is a database example.', [1]) AS highlighted_text;
Drag options to blanks, or click blank then click option'
A'database'
B'This'
C'text'
D'example'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong word to highlight.
Forgetting to put the word in quotes.
2fill in blank
medium

Complete the code to highlight the phrase 'full text' in the given sentence.

PostgreSQL
SELECT ts_headline('english', 'This is a full text search example.', [1]) AS highlighted;
Drag options to blanks, or click blank then click option'
A'full & text'
B'search'
C'full text'
D'example'
Attempts:
3 left
💡 Hint
Common Mistakes
Using plain phrase without tsquery operators.
Not quoting the phrase properly.
3fill in blank
hard

Fix the error in the code to highlight the word 'search' correctly.

PostgreSQL
SELECT ts_headline('english', 'PostgreSQL full text search is powerful.', [1]) AS result;
Drag options to blanks, or click blank then click option'
Asearch
B'search &'
C'search'
D'"search"'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the word to highlight.
Adding unnecessary operators.
4fill in blank
hard

Fill both blanks to highlight the word 'text' in the sentence using ts_headline with configuration 'english'.

PostgreSQL
SELECT ts_headline([1], 'This is a text search example.', [2]) AS highlighted;
Drag options to blanks, or click blank then click option'
A'english'
B'simple'
C'text'
D'search'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the configuration and word arguments.
Using wrong configuration names.
5fill in blank
hard

Fill all three blanks to highlight the phrase 'full text' in the sentence using ts_headline with configuration 'english'.

PostgreSQL
SELECT ts_headline([1], 'This is a full text search example.', [2]) AS highlighted_text WHERE [3];
Drag options to blanks, or click blank then click option'
A'english'
B'full & text'
Ctrue
D'simple'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong configuration names.
Incorrect tsquery phrase syntax.
Leaving WHERE clause empty or invalid.