Complete the code to create a tsvector column named 'document_vector' from the 'content' column.
SELECT to_tsvector([1]) FROM documents;The to_tsvector function converts the text in the content column into a tsvector type for full-text search.
Complete the code to create a tsquery that searches for the word 'database'.
SELECT to_tsquery([1]);The to_tsquery function takes a query string like 'database' to create a tsquery for searching.
Fix the error in the code to match documents containing 'postgres' or 'sql'.
SELECT * FROM documents WHERE document_vector @@ to_tsquery([1]);The | operator means OR in tsquery syntax, so 'postgres | sql' matches documents containing either word.
Fill both blanks to create a tsquery that matches documents containing 'data' but not 'backup'.
SELECT * FROM documents WHERE document_vector @@ to_tsquery([1] [2] 'backup');
| instead of AND &.The & operator means AND, so 'data & !backup' matches documents with 'data' but not 'backup'.
Fill both blanks to create a dictionary comprehension that maps words to their lexemes using to_tsvector and filters lexemes longer than 3 characters.
SELECT jsonb_object_agg(word-> lexeme) FROM (SELECT unnest(string_to_array(content, ' ')) AS word, unnest(to_tsvector([1])::text[]) AS lexeme FROM documents) AS sub WHERE length(lexeme) [2] 3;
-> or < instead of >.The operator -> accesses JSON object fields, content is the text column, and > filters lexemes longer than 3 characters.