github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

dylanz / tsearchable

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 14
    • 5
  • Source
  • Commits
  • Network (5)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

rails tsearch plugin for postgresql 8.3 — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Added index and trigger creation usage in README 
EppO (author)
Fri Sep 26 10:24:24 -0700 2008
commit  5116baf52a9fe9b698381087646cb6791aaddb87
tree    cba08c661c3021b31ff43474848b1bf97cfae8a9
parent  a81b6564c6df2a9cf7e9e0d628873c47507df6e4
tsearchable /
name age
history
message
file README Fri Sep 26 10:24:24 -0700 2008 Added index and trigger creation usage in README [EppO]
file init.rb Thu Jun 19 17:24:38 -0700 2008 initial commit [Dylan Stamat]
directory lib/ Fri Sep 26 10:11:42 -0700 2008 Added rake tasks for vectors and triggers creation [EppO]
directory tasks/ Fri Sep 26 10:11:42 -0700 2008 Added rake tasks for vectors and triggers creation [EppO]
directory test/ Thu Jun 19 17:24:38 -0700 2008 initial commit [Dylan Stamat]
README
NOTE && TODO:  This has been tested on Rails 2.0.2, 2.1.0 and 2.1.1 only.
It contains some activesupport'isms, and... they should definitely be
stripped out and this plugin made into a proper gem.


Description
==============
  This is an extremely light weight interface to postgresql 8.3's built
  in text searching.  There exists an acts_as_tsearch, but this is its
  smaller and built specifically for 8.3, more pointed, brother.
  It lacks many features, but is useful in most text searching scenerios.

  This plugin assumes a lot.  The lot is:
    - Default language used for full text search is english. Use :catalog => 'pg_catalog.french' to change that.
    - GIN index by default.  You can pass in :index => 'GIST' if you'd like to change that.
    - Default tsvector is a coellesced composite of the fields you pass in.
    - OPTIONAL: if you want to use suggestion feature ("do you mean x ?") pg_trgm has to be activated like this: 
    psql database_name < /path_to_your_pg_contrib_folder/pg_trgm.sql
    (see http://www.postgresql.org/docs/8.3/static/pgtrgm.html for more details about pg_trgm)
    


Usage
==============
  - ensure your table has a tsvector ts_index column
    ... in create table block:  t.tsvector :ts_index

  - ensure your model declares text_searchable properly
    ... tsearchable :fields => [:name, :description]

  - create tsvector index and trigger using rake task
    ... rake tsearchable:vectors:create VECTOR=name_of_the_model
    ... rake tsearchable:triggers:create VECTOR=name_of_the_model

  - YourModel.find_by_text_search("moose OR mousse")
    ... returns result set.  supports most googlish ands and ors and double quoting
    ... supports WillPaginate pagination, and the will_paginate view helper

  - YourModel.count_by_text_search("moose OR mousse")
    ... returns the number of matches
  
  OPTIONAL: to use suggestion feature (pg_trgm MUST be activated)
  - ensure your table has a column with gist_trgm_ops or gin_trgm_ops index type
  ... TODO: create rake task to do that
  
  - ensure your model declares suggestion fields
  ... tsearchable :suggests => [ :title ]
  
  - YourModel.find_by_trgm("keyword")
  ... returns result set.

TODO
==============
most importantly... document, and turn it into a gem

also: 
- weighting, highlighting, 
- custom parsers/templates/rankers, 
- multiple vectors, 
- multitable support
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server