texticle

Further documentation available at:

DESCRIPTION:

Texticle exposes full text search capabilities from PostgreSQL, extending ActiveRecord with scopes making search easy and fun!

FEATURES/PROBLEMS:

  • Only works with PostgreSQL

SYNOPSIS:

Quick Start

  • Rails 3

In the project's Gemfile add

gem 'texticle', '~> 2.0', :require => 'texticle/rails'
  • ActiveRecord outside of Rails 3

    require 'texticle'
    ActiveRecord::Base.extend(Texticle)

Usage

Your models now have access to the search method:

Game.search('Sonic') # will search through the model's :string columns
Game.search(:title => 'Mario')
Game.search_by_title('Street Fighter').search_by_system('PS3')
Game.search_by_title_and_system('Final Fantasy', 'PS2')
Game.search_by_title_or_system('Final Fantasy, 'PS3')

Creating Indexes for Super Speed

You can have Postgresql use an index for the full-text search. To declare a full-text index, in a migration add code like the following:

execute "
    create index on email_logs using gin(to_tsvector('english', subject));
    create index on email_logs using gin(to_tsvector('english', email_address));"

In the above example, the table email_logs has two text columns that we search against, subject and email_address. You will need to add an index for every text/string column you query against, or else Postgresql will revert to a full table scan instead of using the indexes.

REQUIREMENTS:

  • ActiveRecord

  • Ruby 1.9.2

INSTALL:

  • gem install texticle

LICENSE:

(The MIT License)

Copyright © 2011 Aaron Patterson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.