Bird
0
0

You run this query:

medium📝 Debug Q14 of 15
PostgreSQL - Full-Text Search
You run this query:
SELECT ts_headline(content, to_tsquery('english', 'search')) FROM documents;

But get an error: function ts_headline(text, tsquery) does not exist. What is the likely cause?
AThe <code>ts_headline</code> function requires a text query string, not tsquery
BThe <code>ts_headline</code> function does not accept <code>to_tsquery</code> results directly
CThe <code>ts_headline</code> function requires three arguments including language
DThe <code>to_tsquery</code> function is used incorrectly without casting
Step-by-Step Solution
Solution:
  1. Step 1: Check function signature

    ts_headline accepts text and tsquery but sometimes requires explicit casting or correct argument types.
  2. Step 2: Identify error cause

    The error suggests no matching function for ts_headline(text, tsquery). This often happens if to_tsquery is used without proper casting or language config mismatch.
  3. Final Answer:

    The to_tsquery function is used incorrectly without casting -> Option D
  4. Quick Check:

    Incorrect to_tsquery usage = B [OK]
Quick Trick: Cast to_tsquery output properly for ts_headline [OK]
Common Mistakes:
  • Assuming ts_headline accepts any tsquery without casting
  • Forgetting to match language configs
  • Confusing argument order or types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes