https://www.freecodecamp.org/news/fuzzy-string-matching-with-postgresql/
extensiones requeridas:
CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION pg_trgm;
CREATE EXTENSION postgis;
sample:
select distinct a.id, a.name,
ST_Distance_Spheroid(a.geom, b.geom, 'SPHEROID["WGS 84",6378137,298.257223563]' ) as d,
b.name2
from table1 a, table2 b
where trim(a.name) = trim(b.name2)
and ST_Distance_Spheroid(a.geom, b.geom, 'SPHEROID["WGS 84",6378137,298.257223563]' ) < 7000
and
(
SIMILARITY(a.name, b.name2 ) > 0.4
or (a.name % b.name2 )
or (SOUNDEX(a.name) = SOUNDEX(b.name2) )
--or (LEVENSHTEIN(a.name, b.name2) < 4 )
)
order by a."IdLoc", ST_Distance_Spheroid(a.geom, b.geom, 'SPHEROID["WGS 84",6378137,298.257223563]'
Encuentra parecidos en el rango de 7Km.//