Bird
0
0

Examine this query:

medium📝 Debug Q6 of 15
PostgreSQL - Full-Text Search

Examine this query:
SELECT * FROM docs WHERE text @@ to_tsquery('search');
Assuming text is a text column, what is the issue?

AThe right operand should be <code>to_tsvector</code>, not <code>to_tsquery</code>
BThe left operand must be a <code>tsvector</code>, not <code>text</code>
CThe operator <code>@@</code> cannot be used in WHERE clauses
DThe query is correct as written
Step-by-Step Solution
Solution:
  1. Step 1: Check operand types

    The @@ operator requires the left operand to be tsvector.
  2. Step 2: Identify the column type

    Here, text is a plain text column, not tsvector.
  3. Step 3: Correct usage

    You must convert text to tsvector using to_tsvector(text) before using @@.
  4. Final Answer:

    The left operand must be a tsvector, not text -> Option B
  5. Quick Check:

    Left side must be tsvector [OK]
Quick Trick: Left operand must be tsvector, not text [OK]
Common Mistakes:
  • Using text column directly without conversion
  • Confusing to_tsquery and to_tsvector functions
  • Assuming @@ works with plain text

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes