How do I use a Levenshtein distance function in a

2019-03-16 19:15发布

I'm trying to implement a "Did you mean?" sort of function for a search.

I'm trying to do a query that uses the levenshtein function, which was written in ruby. I was wondering how I could use this function in a sqlite3 query. I was thinking it might be something like this:

@results = the_db.where('levenshtein(name, ?) <= 3', searchphrase)

But i'm not sure how to get it to work. Could someone help me out?

1条回答
霸刀☆藐视天下
2楼-- · 2019-03-16 20:07

Try the editdist3 function:

The editdist3 algorithm is a function that computes the minimum edit distance (a.k.a. the Levenshtein distance) between two input strings.

查看更多
登录 后发表回答