Bird
0
0

Given the following SQL commands:

medium📝 query result Q13 of 15
PostgreSQL - Full-Text Search
Given the following SQL commands:
CREATE TEXT SEARCH CONFIGURATION my_english ( COPY = english );
ALTER TEXT SEARCH CONFIGURATION my_english
  ALTER MAPPING FOR asciiword, asciihword, hword_asciipart
  WITH simple;
SELECT to_tsvector('my_english', 'PostgreSQL is great!');

What is the output of the SELECT statement?
A'postgresql':1 'great':3 'is':2 'simple':5
B'postgresql':1 'great':3 'is':2
C'postgresql':1 'great':3
DSyntax error due to ALTER MAPPING
Step-by-Step Solution
Solution:
  1. Step 1: Understand ALTER MAPPING effect

    The ALTER MAPPING changes how asciiword and related tokens are processed, using the simple dictionary which does not remove stop words.
  2. Step 2: Analyze to_tsvector output

    The text 'PostgreSQL is great!' produces tokens: 'PostgreSQL' (pos 1, asciiword) -> 'postgresql':1; 'is' (pos 2, asciiword) -> 'is':2; 'great' (pos 3, asciiword) -> 'great':3. Simple indexes all without dropping stopwords. Matches 'postgresql':1 'great':3 'is':2.
  3. Final Answer:

    'postgresql':1 'great':3 'is':2 -> Option B
  4. Quick Check:

    Alter mapping changes dictionary used [OK]
Quick Trick: ALTER MAPPING changes dictionary for word processing [OK]
Common Mistakes:
  • Assuming stop words are always removed
  • Confusing dictionary effects on stemming and stop words
  • Expecting syntax error from ALTER MAPPING

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes