跳转到主要内容

addressing_dictionary

面向地址缩写归一化的全文检索词典与配置

概览

扩展包名版本分类许可证语言
addressing_dictionary1.1FTSMITSQL
ID扩展名BinLibLoadCreateTrustReloc模式
2270addressing_dictionary否否否是否是-

SQL and dictionary data only; no shared library. PostgreSQL 14-18 verified in PGSTY builds; upstream declares no current major-version matrix.

版本

类型仓库版本PG 大版本包名依赖
EXTPIGSTY1.11817161514addressing_dictionary-
RPMPIGSTY1.11817161514addressing_dictionary_$v-
DEBPIGSTY1.11817161514postgresql-$v-addressing-dictionary-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el8.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el9.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el9.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el10.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
el10.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
d12.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
d12.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
d13.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
d13.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u22.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u22.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u24.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u24.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u26.x86_64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
u26.aarch64
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1
PIGSTY 1.1

构建

您可以使用 pig build 命令构建 addressing_dictionary 扩展的 RPM / DEB 包:

pig build pkg addressing_dictionary         # 构建 RPM / DEB 包

安装

您可以直接安装 addressing_dictionary 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:

pig repo add pgsql -u          # 添加仓库并更新缓存

使用 pig 或者是 apt/yum/dnf 安装扩展:

安装
pig install addressing_dictionary;          # 当前活跃 PG 版本安装
pig
pig ext install -y addressing_dictionary -v 18  # PG 18
pig ext install -y addressing_dictionary -v 17  # PG 17
pig ext install -y addressing_dictionary -v 16  # PG 16
pig ext install -y addressing_dictionary -v 15  # PG 15
pig ext install -y addressing_dictionary -v 14  # PG 14
dnf
dnf install -y addressing_dictionary_18       # PG 18
dnf install -y addressing_dictionary_17       # PG 17
dnf install -y addressing_dictionary_16       # PG 16
dnf install -y addressing_dictionary_15       # PG 15
dnf install -y addressing_dictionary_14       # PG 14
apt
apt install -y postgresql-18-addressing-dictionary   # PG 18
apt install -y postgresql-17-addressing-dictionary   # PG 17
apt install -y postgresql-16-addressing-dictionary   # PG 16
apt install -y postgresql-15-addressing-dictionary   # PG 15
apt install -y postgresql-14-addressing-dictionary   # PG 14

创建扩展:

CREATE EXTENSION addressing_dictionary;

用法

来源:

addressing_dictionary 安装面向地址的全文搜索配置与词典。它适合在本地地址近似检索中,把街道类型、方向和序数的不同写法归一为可比较的词位;它不是地理编码器,也不能替代地址解析与校验。

核心流程

在数据库中安装一次扩展,用所提供的配置归一化地址文本,并让索引表达式与查询表达式保持一致。

CREATE EXTENSION addressing_dictionary;

SELECT to_tsvector('addressing_en', '1234 n main st');

CREATE INDEX address_search_idx
ON address_book
USING gin (to_tsvector('addressing_en', full_address));

SELECT *
FROM address_book
WHERE to_tsvector('addressing_en', full_address)
      @@ plainto_tsquery('addressing_en', '1234 north main street');

1.1 版会保留方向缩写,同时产生展开形式,因此单字母的北向标记可以输出两种形式。这种设计刻意保留歧义,而不会假定每次出现都只有一种含义。

已安装对象

  • 英文配置把地址标记的同义词词典、停用词词典和叙词表组合起来。
  • 法文配置安装对应的法文文本搜索对象。
  • 两套配置都复制自 PostgreSQL 的简单配置,因此通过扩展的数据文件归一化,而不是使用通用语言词干提取器。

运维边界

该扩展可重定位,不需要预加载或重启。所有可能执行查询或恢复扩展的服务器都必须安装其词典、同义词、停用词和叙词表文件。

全文匹配属于启发式方法。缩写可能有歧义,全国范围的数据也可能产生大量误匹配或重复候选。应把它用于改进候选检索,尤其是范围有限的城市或地区;对正确性有要求时,仍需另外使用结构化地址或地理空间检查。

这个页面对您有帮助吗?