我想做什么;
我有两个包含两个地址列的表,都存储为text
我想创建一个返回匹配行的视图。
我尝试了什么;
我已在列和表上创建并编制索引,如下所示;
CREATE INDEX idx_table1_fulladdress ON table1 (LOWER(fulladdress_ppd));
然后运行以下内容;
CREATE OR REPLACE VIEW view_adresscheck AS
SELECT
--from table1
table1.postcode,
table1.fulladdress_ppd,
--from table2
table2.epc_postcode,
table2.fulladdress_epc
FROM
table1,
table2
WHERE
table1.postcode = table2.epc_postcode
AND
table2.fulladdress_epc = table1.fulladdress_ppd ::text;
什么没有用? 上面返回的记录比我知道的要少。在检查时,这是因为两个表之间的地址格式不一致,即。
table1.fulladdress_ppd = Flat 2d The building the street
table2.fulladdress_epc = Flat 2/d The building the street, the town
地址在表格中的格式一致,即table
并非所有地址都包含城镇,因此我无法使用regex
或trim
批量清理。
我在postgres中看到了fuzzystrmatch
module,这听起来好像可以解决我的问题。
问题 哪个Soundex,Levenshtein,Metaphone最合适。大多数记录都是英文的,一些地名是Gaelic在9.6上运行。
答案 0 :(得分:0)
从不同来源的匹配地址的经验谈起。你能做的是索引每个地址。无论格式化上述地址都会返回相同的数字。然后匹配这些索引。
例如,在英国,您拥有该国每个邮政地址所谓的UDPRN号码。