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

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

百科 / 函数百科 / 文本检索函数和操作符

FUNCTION文本检索函数和操作符

unnest

将tsvector展开为一组行,每行对应一个词位。

Expands a tsvector into a set of rows, one per lexeme.

文本检索函数和操作符 引入 9.0(基线) 现存至 20 devel 4 条签名 3 次签名变更

签名数
4 条
引入版本
9.0(基线)
状态
现存
签名变更
3 次
本版来源
本站译文

PostgreSQL 18 手册 · 9.13 文本检索函数和操作符 官方文档

版本轨迹

相对 PostgreSQL 17 无变化。

签名

PostgreSQL 18 里 unnest 的 4 条签名,按上游手册顺序排列。参数名用斜体,类型用弱化色, 之后是返回类型。说明取自本站手册译文:标「沿用」的借用了另一版的译文,标「EN」的本站暂无译文、按英文原文显示。

  1. unnest ( tsvector ) → setof record ( lexeme text, positions smallint[], weights text )

    将tsvector展开为一组行,每行对应一个词位。
    • select * from unnest('cat:3 fat:2,4 rat:5A'::tsvector) lexeme | positions | weights --------+-----------+--------- cat | {3} | {D} fat | {2,4} | {D,D} rat | {5} | {A}
  2. unnest ( anyarray ) → setof anyelement

    将数组展开到一组行。数组的元素按存储顺序读出。
    • unnest(ARRAY[1,2])1 2
    • unnest(ARRAY[['foo','bar'],['baz','quux']])foo bar baz quux
  3. unnest ( anyarray, anyarray [, ... ] ) → setof anyelement, anyelement [, ... ]

    将多个数组(可能是不同的数据类型)展开到一组行中。如果数组的长度不完全相同,那么较短的数组将用NULL填充。这种形式只允许出现在查询的 FROM 子句中;参见第 7.2.1.4 节。
    • select * from unnest(ARRAY[1,2], ARRAY['foo','bar','baz']) as x(a,b) a | b ---+----- 1 | foo 2 | bar | baz
  4. unnest ( anymultirange ) → setof anyrange

    将多范围按升序展开为一组范围。
    • unnest('{[1,2), [3,4)}'::int4multirange)[1,2) [3,4)

演化历史

相邻两个大版本之间的差异,新的在前。版本号链到该版的签名。

  1. PostgreSQL 14 ← 13 签名变更

    unnest ( anymultirange ) → setof anyrange

  2. PostgreSQL 13 ← 12 手册重排

    这一跳手册重排了函数表的写法,签名文本整体改写,只记函数的增删,不逐条比较签名。

  3. PostgreSQL 9.6 ← 9.5 签名变更

    unnest ( tsvector, OUT lexeme text, OUT positions smallint[], OUT weights text ) → setof record arraytextsearch 说明更新

  4. PostgreSQL 9.4 ← 9.3 签名变更

    unnest ( anyarray, anyarray [, ...] ) → setof anyelement, anyelement [, ...]

签名矩阵

每条签名在给出了签名的 18 个版本里的存在情况;方格指向该版的签名。只在正文里提到此函数、没有给出签名的版本不列进来,上面的版本轨迹里仍然有它们。签名文本在 PostgreSQL 13 前后写法不同,跨越那一跳的同一条签名会显示成两行。

存在 不存在

签名 9.09.19.29.39.49.59.61011121314151617181920
unnest ( anyarray ) → setof anyelement 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
unnest ( anyarray, anyarray [, ...] ) → setof anyelement, anyelement [, ...] 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在 存在
unnest ( tsvector, OUT lexeme text, OUT positions smallint[], OUT weights text ) → setof record 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在
unnest ( tsvector ) → setof record ( lexeme text, positions smallint[], weights text ) 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 存在 存在 存在
unnest ( anymultirange ) → setof anyrange 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 不存在 存在 存在 存在 存在 存在 存在 存在

同组函数

函数 签名 主签名 版本变动 最近变更
TEXT SEARCH FUNCTIONS AND OPERATORS 文本检索函数和操作符 27 个 ↗
array_to_tsvector 1 array_to_tsvector ( text[] ) → tsvector —
将文本字符串数组转换为tsvector。 现存
get_current_ts_config基线 1 get_current_ts_config ( ) → regconfig —
返回当前默认文本检索配置的 OID(由default_text_search_config设置)。 现存
json_to_tsvector 1 json_to_tsvector ( [config regconfig, ] document json, filter jsonb ) → tsvector —
选择filter请求的JSON文档中的每个项,并将每个项转换为tsvector,根据指定的或默认配置对单词进行正规化。 现存
jsonb_to_tsvector 1 jsonb_to_tsvector ( [config regconfig, ] document jsonb, filter jsonb ) → tsvector —
选择filter请求的JSON文档中的每个项,并将每个项转换为tsvector,根据指定的或默认配置对单词进行正规化。 现存
numnode基线 1 numnode ( tsquery ) → integer —
返回tsquery中词位和操作符的数目。 现存
phraseto_tsquery 1 phraseto_tsquery ( [config regconfig, ] query text ) → tsquery —
将文本转换为tsquery,根据指定的或默认配置对单词进行正规化。 现存
plainto_tsquery基线 1 plainto_tsquery ( [config regconfig, ] query text ) → tsquery —
将文本转换为tsquery,根据指定的或默认配置对单词进行正规化。 现存
querytree基线 1 querytree ( tsquery ) → text —
生成tsquery中可索引部分的表示。 现存
setweight基线 2 setweight ( vector tsvector, weight "char" ) → tsvector 9.61 次
将指定的weight赋给vector的每个元素。 现存
strip基线 1 strip ( tsvector ) → tsvector —
从tsvector中移除位置和权重。 现存
to_tsquery基线 1 to_tsquery ( [config regconfig, ] query text ) → tsquery —
将文本转换为tsquery,根据指定的或默认配置对单词进行正规化。 现存
to_tsvector基线 3 to_tsvector ( [config regconfig, ] document text ) → tsvector 101 次
将文本转换为tsvector,根据指定的或默认配置对单词进行正规化。 现存
ts_debug基线 1 ts_debug ( [config regconfig, ] document text ) → setof record ( alias text, description text, token text, dictionaries regdictionary[], dictionary regdictionary, lexemes text[] ) —
根据指定的或默认的文本检索配置从document中提取和正规化词元,并返回关于每个词元是如何处理的信息。 现存
ts_delete 2 ts_delete ( vector tsvector, lexeme text ) → tsvector —
从vector中删除给定的lexeme的所有出现。 现存
ts_filter 1 ts_filter ( vector tsvector, weights "char"[] ) → tsvector —
只从vector中选择具有给定weights的元素。 现存
ts_headline基线 3 ts_headline ( [config regconfig, ] document text, query tsquery [, options text] ) → text 101 次
以缩略形式显示query在document中的匹配项;后者必须是原始文本,不能是tsvector。 现存
ts_lexize基线 1 ts_lexize ( dict regdictionary, token text ) → text[] —
如果词典识别输入词元,则返回由替换词位组成的数组;如果词典识别该词元,但它是停用词,则返回空数组;如果词典无法识别该词元,则返回NULL。 现存
ts_parse基线 2 ts_parse ( parser_name text, document text ) → setof record ( tokid integer, token text ) —
使用指定名称的解析器从document中提取词元。 现存
ts_rank基线 1 ts_rank ( [weights real[], ] vector tsvector, query tsquery [, normalization integer] ) → real —
计算一个分数,显示vector与query的匹配程度。 现存
ts_rank_cd基线 1 ts_rank_cd ( [weights real[], ] vector tsvector, query tsquery [, normalization integer] ) → real —
使用覆盖密度算法计算一个分数,显示vector与query的匹配程度。 现存
ts_rewrite基线 2 ts_rewrite ( query tsquery, target tsquery, substitute tsquery ) → tsquery —
在query中使用 substitute替换出现的target。 现存
ts_stat基线 1 ts_stat ( sqlquery text [, weights text] ) → setof record ( word text, ndoc integer, nentry integer ) —
执行sqlquery,该查询必须返回单个tsvector列,并返回数据中每个不同词位的统计信息。 现存
ts_token_type基线 2 ts_token_type ( parser_name text ) → setof record ( tokid integer, alias text, description text ) —
返回一个表,该表描述指定名称的解析器可以识别的每种类型的词元。 现存
tsquery_phrase 2 tsquery_phrase ( query1 tsquery, query2 tsquery ) → tsquery —
构造一个短语查询,在连续的词位上搜索query1和query2的匹配项(与<->操作符相同)。 现存
tsvector_to_array 1 tsvector_to_array ( tsvector ) → text[] —
将tsvector转换为词位的数组。 现存
unnest基线 4 unnest ( tsvector ) → setof record ( lexeme text, positions smallint[], weights text ) 143 次
将tsvector展开为一组行,每行对应一个词位。 现存
websearch_to_tsquery 1 websearch_to_tsquery ( [config regconfig, ] query text ) → tsquery —
将文本转换为tsquery,根据指定的或默认配置对单词进行正规化。 现存