Bird
0
0

What will be the result of:

medium📝 query result Q5 of 15
PostgreSQL - Full-Text Search
What will be the result of:
SELECT to_tsvector('english', 'Cats and dogs') @@ to_tsquery('english', 'cat | dog');
Afalse
Btrue
CSyntax error
DNULL
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the tsvector and tsquery

    to_tsvector converts 'Cats and dogs' to tokens 'cat' and 'dog' (stemmed). The to_tsquery searches for 'cat' OR 'dog'.

  2. Step 2: Evaluate the OR condition

    Since both 'cat' and 'dog' appear, the OR condition is true.

  3. Final Answer:

    true -> Option B
  4. Quick Check:

    OR in tsquery returns true if any token matches [OK]
Quick Trick: Use | for OR in tsquery expressions [OK]
Common Mistakes:
  • Expecting false because of plural forms
  • Confusing & and | operators
  • Assuming syntax error for |

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes