If your working with a Ruby/Rails app, check out the pg_search gem https://github.com/Casecommons/pg_search
It allows you to do the things in this article with ActiveRecord models.
It allows you to do the things in this article with ActiveRecord models.