SQL practice: Full-Text Search: Beyond LIKE

Chapter 41 · 7 questions · included in full access

  1. Question 1 · easy

    Convert the text 'South Facade Works' into a tsvector using the english configuration, in a column named doc.

    Solve it in your browser
  2. Question 2 · easy

    List the customer_name of every customer whose name matches the search term 'facade', using to_tsvector and to_tsquery. Order by customer_name.

    Solve it in your browser
  3. Question 3 · medium

    Find customers matching both 'panel' and 'house', using plainto_tsquery so the words can be passed in as a plain phrase. Show customer_name, ordered by customer_name.

    Solve it in your browser
  4. Question 4 · medium

    Use websearch_to_tsquery to find customers matching the phrase "facade works", quoted so the words must be adjacent. Show customer_name, ordered by customer_name.

    Solve it in your browser
  5. Question 5 · medium

    Rank customers against the query 'facade' and show customer_name with the score in a column named rank, best first, then by name.

    Solve it in your browser
  6. Question 6 · hard

    Find every product whose name matches 'sheet' but not 'silver', using to_tsquery with the & and ! operators. Show product_name, ordered by product_name.

    Solve it in your browser
  7. Question 7 · hard

    You add a GIN index on to_tsvector(customer_name) but your queries use to_tsvector('english', customer_name). Why is the index never used?

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing