↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Functions / Text Search Functions And Operators

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

Reading PG 18current·documented in 19 of 27 versions, 8.4 to 20

Signatures & examples

unnest ( tsvector ) → setof record ( lexeme text, positions smallint[], weights text )
Expands a tsvector into a set of rows, one per lexeme.
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}
unnest ( anyarray ) → setof anyelement
Expands an array into a set of rows. The array's elements are read out in storage order.
unnest(ARRAY[1,2]) → 1
2
unnest(ARRAY[['foo','bar'],['baz','quux']]) → foo
bar
baz
quux
unnest ( anyarray, anyarray [, ... ] ) → setof anyelement, anyelement [, ... ]
Expands multiple arrays (possibly of different data types) into a set of rows. If the arrays are not all the same length then the shorter ones are padded with NULLs. This form is only allowed in a query's FROM clause; see Section 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
unnest ( anymultirange ) → setof anyrange
Expands a multirange into a set of ranges in ascending order.
unnest('{[1,2), [3,4)}'::int4multirange) → [1,2)
[3,4)
Version history 5
  1. 13 → 14 changed
  2. 12 → 13 changed
  3. 9.5 → 9.6 changed
  4. 9.3 → 9.4 changed
  5. 8.3 → 8.4 added

Definition snapshot: b7bd9cda · English manual source