BaşlayınÜcretsiz Başlayın

Levenshtein distance examples

Now let's take a closer look at how we can use the levenshtein function to match strings against text data. If you recall, the levenshtein distance represents the number of edits required to convert one string to another string being compared.

In a search application or when performing data analysis on any data that contains manual user input, you will always want to account for typos or incorrect spellings. The levenshtein function provides a great method for performing this task. In this exercise, we will perform a query against the film table using a search string with a misspelling and use the results from levenshtein to determine a match. Let's check it out.

Bu egzersiz

Functions for Manipulating Data in PostgreSQL

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Select the film title and film description.
  • Calculate the levenshtein distance for the film title with the string JET NEIGHBOR.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

-- Select the title and description columns
SELECT  
  ___, 
  ___, 
  -- Calculate the levenshtein distance
  ___(___, ___) AS distance
FROM 
  film
ORDER BY 3
Kodu Düzenle ve Çalıştır