Art*_*tem 3 postgresql levenshtein-distance
我有postgreSQL 9.2
我的任务是在表格中找到相似的名字(受到一些levenshtain距离的限制).
例如,距离为3,表格包含数据:
| name |
|***************************|
| Marcus Miller |
| Marcos Miller |
| Macus Miler |
| David Bowie |
| Dave Grohl |
| Dav Grol |
| ... |
Run Code Online (Sandbox Code Playgroud)
我想得到的结果是这样的:
| Marcus Miller, Marcos Miller, Macus Miler |
| Dave Grohl, Dav Grol |
| ... |
Run Code Online (Sandbox Code Playgroud)
要么
| Marcus Miller, Marcos Miller |
| Marcus Miller, Macus Miler |
| Dave Grohl, Dav Grol |
| ... |
Run Code Online (Sandbox Code Playgroud)
我试过这个:
SELECT a.name, b.name
FROM my_table a
JOIN my_table b ON b.id < a.id AND levenshtein(b.name, a.name) < 3;
Run Code Online (Sandbox Code Playgroud)
但是我的数据太慢了.
归档时间: |
|
查看次数: |
1174 次 |
最近记录: |