Challenge - 5 Problems
Full-Text Search Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this tsquery match?
Given the following SQL query, what is the result of the match condition?
PostgreSQL
SELECT to_tsvector('english', 'The quick brown fox') @@ to_tsquery('english', 'quick & fox') AS match_result;
Attempts:
2 left
💡 Hint
Check if both words 'quick' and 'fox' appear in the tsvector.
✗ Incorrect
The tsvector contains 'quick' and 'fox', and the tsquery requires both with '&', so the match is true.
📝 Syntax
intermediate2:00remaining
Which option correctly creates a tsquery for phrase search?
Which SQL statement correctly creates a tsquery to search for the phrase 'data science'?
Attempts:
2 left
💡 Hint
Phrase search uses the <-> operator between words.
✗ Incorrect
The <-> operator specifies that 'data' must be immediately followed by 'science', which is a phrase search.
❓ optimization
advanced2:00remaining
How to optimize full-text search on a large text column?
You have a large table with a text column 'content'. Which approach optimizes full-text search performance?
Attempts:
2 left
💡 Hint
Full-text search uses tsvector and GIN indexes for speed.
✗ Incorrect
GIN indexes on tsvector columns speed up full-text search queries efficiently.
🔧 Debug
advanced2:00remaining
Why does this tsquery return no matches?
Given the query below, why does it return no rows?
SELECT * FROM articles WHERE to_tsvector('english', body) @@ to_tsquery('simple', 'cats & dogs');
Attempts:
2 left
💡 Hint
Check how stemming affects word forms in tsvector and tsquery.
✗ Incorrect
The tsvector stems 'cats' to 'cat' but the tsquery uses 'cats' which does not stem, so no match occurs.
🧠 Conceptual
expert2:00remaining
What is the difference between plainto_tsquery and to_tsquery?
Choose the correct statement about plainto_tsquery and to_tsquery functions in PostgreSQL.
Attempts:
2 left
💡 Hint
Think about how each function interprets input text.
✗ Incorrect
plainto_tsquery treats input as plain text and combines words with AND; to_tsquery expects explicit tsquery syntax with operators.