↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 全文检索组件 / 配置

armenian

全文检索配置 armenian。

当前查看 PostgreSQL 18.6。

说明

全文检索配置 armenian。

配置
armenian
解析器
默认

initdb 生成的定义

根据此版本的 Snowball 语言列表和 SQL 模板生成。

/*
 * text search configuration for armenian language
 *
 * Copyright (c) 2007-2025, PostgreSQL Global Development Group
 *
 * src/backend/snowball/snowball.sql.in
 *
 * armenian and certain other macros are replaced for each language;
 * see the Makefile for details.
 *
 * Note: this file is read in single-user -j mode, which means that the
 * command terminator is semicolon-newline-newline; whenever the backend
 * sees that, it stops and executes what it's got.  If you write a lot of
 * statements without empty lines between, they'll all get quoted to you
 * in any error message about one of them, so don't do that.  Also, you
 * cannot write a semicolon immediately followed by an empty line in a
 * string literal (including a function body!) or a multiline comment.
 */

CREATE TEXT SEARCH DICTIONARY armenian_stem
	(TEMPLATE = snowball, Language = armenian );

COMMENT ON TEXT SEARCH DICTIONARY armenian_stem IS 'snowball stemmer for armenian language';

CREATE TEXT SEARCH CONFIGURATION armenian
	(PARSER = default);

COMMENT ON TEXT SEARCH CONFIGURATION armenian IS 'configuration for armenian language';

ALTER TEXT SEARCH CONFIGURATION armenian ADD MAPPING
	FOR email, url, url_path, host, file, version,
	    sfloat, float, int, uint,
	    numword, hword_numpart, numhword
	WITH simple;

ALTER TEXT SEARCH CONFIGURATION armenian ADD MAPPING
    FOR asciiword, hword_asciipart, asciihword
	WITH armenian_stem;

ALTER TEXT SEARCH CONFIGURATION armenian ADD MAPPING
    FOR word, hword_part, hword
	WITH armenian_stem;

词元到词典的映射

词元类型顺序词典
email1简单
url1简单
url_path1简单
host1简单
file1简单
version1简单
sfloat1简单
float1简单
int1简单
uint1简单
numword1简单
hword_numpart1简单
numhword1简单
asciiword1armenian_stem
hword_asciipart1armenian_stem
asciihword1armenian_stem
word1armenian_stem
hword_part1armenian_stem
hword1armenian_stem

手册定义

12.7. 配置示例

一个文本检索配置指定了将一个文档转换成一个tsvector所需的所有选项:用于把文本分解成词元的解析器,以及用于将每一个词元转换成词位的词典。每一次to_tsvector或to_tsquery的调用都需要一个文本检索配置来执行其处理。配置参数default_text_search_config指定了默认配置的名称,如果省略了显式的配置参数,文本检索函数将会使用它。它可以在postgresql.conf中设置,或者使用SET命令为一个单独的会话设置。

有一些预定义的文本检索配置可用,并且你可以容易地创建自定义的配置。为了便于管理文本检索对象,可以使用一组SQL命令,并且有多个psql命令可以显示有关文本检索对象(第 12.10 节)的信息。

作为一个示例,我们将创建一个配置pg,从复制内置的english配置开始:

CREATE TEXT SEARCH CONFIGURATION public.pg ( COPY = pg_catalog.english );

我们将使用一个 PostgreSQL 相关的同义词列表,并将它存储在$SHAREDIR/tsearch_data/pg_dict.syn中。文件内容看起来像:

postgres    pg
pgsql       pg
postgresql  pg

我们定义同义词词典如下:

CREATE TEXT SEARCH DICTIONARY pg_dict (
    TEMPLATE = synonym,
    SYNONYMS = pg_dict
);

接下来我们注册Ispell词典english_ispell,它有其自己的配置文件:

CREATE TEXT SEARCH DICTIONARY english_ispell (
    TEMPLATE = ispell,
    DictFile = english,
    AffFile = english,
    StopWords = english
);

现在我们可以在配置pg中建立词的映射:

ALTER TEXT SEARCH CONFIGURATION pg
    ALTER MAPPING FOR asciiword, asciihword, hword_asciipart,
                      word, hword, hword_part
    WITH pg_dict, english_ispell, english_stem;

我们选择不索引或搜索某些内置配置确实处理的词元类型:

ALTER TEXT SEARCH CONFIGURATION pg
    DROP MAPPING FOR email, url, url_path, sfloat, float;

现在我们可以测试我们的配置:

SELECT * FROM ts_debug('public.pg', '
PostgreSQL, the highly scalable, SQL compliant, open source object-relational
database management system, is now undergoing beta testing of the next
version of our software.
');

下一步是把会话设置为使用这个新配置,该配置是在 public 模式中创建的:

=> \dF
   List of text search configurations
 Schema  | Name | Description
---------+------+-------------
 public  | pg   |

SET default_text_search_config = 'public.pg';
SET

SHOW default_text_search_config;
 default_text_search_config
----------------------------
 public.pg

相关条目

文档与源码

来源构建
版本
18.6
构建
https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2
来源指纹
555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f

版本比较

PostgreSQL 13 → 14: 新增收录。

以下差异保留原始字段名与英文源描述。

--- PostgreSQL 13
+++ PostgreSQL 14
@@ -1 +1,100 @@
-该版未收录
+{
+  "mappings": [
+    {
+      "dictionary": "armenian_stem",
+      "sequence": "1",
+      "token": "asciihword"
+    },
+    {
+      "dictionary": "armenian_stem",
+      "sequence": "1",
+      "token": "asciiword"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "email"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "file"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "float"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "host"
+    },
+    {
+      "dictionary": "armenian_stem",
+      "sequence": "1",
+      "token": "hword"
+    },
+    {
+      "dictionary": "armenian_stem",
+      "sequence": "1",
+      "token": "hword_asciipart"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "hword_numpart"
+    },
+    {
+      "dictionary": "armenian_stem",
+      "sequence": "1",
+      "token": "hword_part"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "int"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "numhword"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "numword"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "sfloat"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "uint"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "url"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "url_path"
+    },
+    {
+      "dictionary": "simple",
+      "sequence": "1",
+      "token": "version"
+    },
+    {
+      "dictionary": "armenian_stem",
+      "sequence": "1",
+      "token": "word"
+    }
+  ],
+  "parser": "default"
+}

比较已记录的接口与属性,排除来源指纹和构建元数据。某个样本中没有记录,不能据此判断实际引入或移除的版本。

相关条目

导出 JSON · 返回全文检索组件 · 收录范围为 PostgreSQL 14 至 20;最早采样版本不一定是实际引入版本。