Bird
0
0

Given the query:

medium📝 query result Q4 of 15
PostgreSQL - Full-Text Search
Given the query:
SELECT ts_headline('english', 'PostgreSQL is great for text search', to_tsquery('english', 'text'));
What is the expected output?
A'PostgreSQL is <b>great</b> for text search'
B'PostgreSQL is great for text search'
C'<b>PostgreSQL</b> is great for text search'
D'PostgreSQL is great for <b>text</b> search'
Step-by-Step Solution
Solution:
  1. Step 1: Understand the tsquery used

    The query searches for the word 'text' in the document.
  2. Step 2: Identify which word is highlighted

    Only the word 'text' matches and should be highlighted with tags.
  3. Final Answer:

    'PostgreSQL is great for text search' -> Option D
  4. Quick Check:

    Highlight matches = 'text' [OK]
Quick Trick: Only matched words get highlighted [OK]
Common Mistakes:
  • Highlighting wrong words
  • No highlighting at all
  • Highlighting multiple unrelated words

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes