I would like to know if its possible to create a Postgres function to scan some table rows and create a table that contains WORD and AMOUNT (frequency)? My goal is to use this table to create a Word Cloud.
I would like to know if its possible to create a Postgres function to
Share
There is a simple way, but it can be slow (depending on your table size). You can split your text into an array:
With those arrays, you can use
unnestto aggregate them:This is a simple way of doing that and, has some issues, like, it only split words by space not punctuation marks.
Other, and probably better option, is to use PostgreSQL full text search.