Is there a way to filter a django queryset based on string similarity (a la python difflib)?

后端 未结 3 1468
陌清茗
陌清茗 2020-12-31 18:17

I have a need to match cold leads against a database of our clients.

The leads come from a third party provider in bulk (thousands of records) and sales is asking u

3条回答
  •  不知归路
    2020-12-31 18:38

    soundex won't help you, because it's a phonetic algorithm. Joe and Joseph aren't similar phonetically, so soundex won't mark them as similar.

    You can try Levenshtein distance, which is implemented in PostgreSQL. Maybe in your database too and if not, you should be able to write a stored procedure, which will calculate the distance between two strings and use it in your computation.

提交回复
热议问题