N
N
Nassaii2018-10-08 13:59:25
PostgreSQL
Nassaii, 2018-10-08 13:59:25

Is it possible to display the number of unique words in a table?

Hello. Tell me, is it possible to display a list of unique words and their number in the table?
There is a text column that can contain either one word or several sentences. A full-text index gin_trgm_ops was created on this column, which, as far as I know, divides all the lines into separate words. But how to make a query (and whether it is possible) to display individual words and their number is not clear.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2018-10-08
@melkij

select lexeme, count(*) from tabledata cross join unnest(to_tsvector(data)) as lexemes group by 1;

?
gin_trgm_ops - NOT a full text index and does not perform word division. This is a pg_trgm extension with a trigram search implementation. Relevant to text, but not fulltext search at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question