Home > Enterprise >  split strings inside a tsvector
split strings inside a tsvector

Time:09-06

I have a tsvector with values of strings(text) inside it. I want to preform the split_part() function of postgres for each element inside the tsvector and to get a table with those values. Is it possible?

Example:

tsvector: 'hello' 'world' 'thank you'

output after performing split_part(elementOfTsvector, 'o', 1) on each element:

Table:

'hell'

'w'

'thank y'

CodePudding user response:

You can use unnest() on tsvectors to get lexemes.

select split_part(lexeme, 'o', 1) from unnest('hello world ''thank you'''::tsvector); 
  • Related