0
0
PostgreSQLquery~10 mins

to_tsquery for search terms in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a text search query for the term 'cat'.

PostgreSQL
SELECT to_tsquery([1]);
Drag options to blanks, or click blank then click option'
A"cat"
Bcat
C'cat & dog'
D'cat'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the single quotes around the search term.
Using double quotes instead of single quotes.
2fill in blank
medium

Complete the code to create a text search query for the phrase 'cat & dog'.

PostgreSQL
SELECT to_tsquery([1]);
Drag options to blanks, or click blank then click option'
A'cat dog'
B'cat | dog'
C'cat & dog'
D'cat && dog'
Attempts:
3 left
💡 Hint
Common Mistakes
Using spaces without operators between words.
Using double ampersands instead of a single ampersand.
3fill in blank
hard

Fix the error in the code to correctly create a text search query for 'cat | dog'.

PostgreSQL
SELECT to_tsquery([1]);
Drag options to blanks, or click blank then click option'
A'cat | dog'
B'cat or dog'
C'cat & dog'
Dcat | dog
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word 'or' instead of the | operator.
Not enclosing the query in single quotes.
4fill in blank
hard

Fill both blanks to create a text search query that searches for 'cat' AND 'dog' but NOT 'mouse'.

PostgreSQL
SELECT to_tsquery([1]); -- 'cat & dog [2] mouse'
Drag options to blanks, or click blank then click option'
A'cat & dog'
B'cat | dog'
C&!
D|!
Attempts:
3 left
💡 Hint
Common Mistakes
Using '|!' instead of '&!' for AND NOT.
Not combining operators correctly.
5fill in blank
hard

Fill all three blanks to create a text search query that searches for 'cat' OR 'dog' AND excludes 'mouse'.

PostgreSQL
SELECT to_tsquery([1]); -- 'cat [2] dog [3] mouse'
Drag options to blanks, or click blank then click option'
A'cat'
B'dog'
C|!
D|
Attempts:
3 left
💡 Hint
Common Mistakes
Using AND operator instead of OR.
Not combining OR and NOT correctly.