Text Search on Postgres

reduce your text search dependencies

The Pros and Cons

make sure textacular is right for you

Getting Up and Running

add text search to your models in 5 minutes flat

For Rails 3 Apps

  • Inside your Gemfile
  • gem 'textacular', "~> 3.0", require: 'textacular/rails'

  • To verify, from a terminal
  • bundle install
  • bundle | grep textacular # => Using textacular (…)

Outside of a Rails app

  • require 'activerecord'
  • require 'textacular'
  • ActiveRecord::Base.extend(Textacular)

Search Your Models

forget about LIKE %

Tips and Tricks

get the most out of textacular

Systemwide Search

If you have several models you want to search through in one go, one approach is to use a separate search model. First populate a database view with the models you want to search through:

Now we can write our Search model:

Running Search.new('awesome') will return all authors AND books that have 'awesome' in their name or title.

Limit Searched Columns with Searchable

If you don't wish to search across all your text columns, you an include Searchable with a list of columns to whitelist in searches:

As you can see, _why can't be found.

Scope Searches

It's also possible to limit which columns are searched through judicious use of scopes:


this gem brought to you by the following committers