Code Monkey home page Code Monkey logo

texticle's Introduction

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')

You can use ‘|’ and ‘&’ for logical conditions.

Game.search_by_title_or_system('Final Fantasy', 'PS3|Xbox')

Setting Language

To set proper searchig dictionary just override class method on your model:

def self.searchable_language
  'russian'
end

And all your queries would go right! And don`t forget to change the migration for indexes, like shown below.

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.

If you create these indexes, you should also switch to sql for your schema_format in ‘config/application.rb`:

config.active_record.schema_format = :sql

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.

texticle's People

Contributors

ecin avatar tenderlove avatar kronn avatar flavorjones avatar benhamill avatar adamsanderson avatar yesezra avatar muxamilian avatar sj26 avatar nathanvda avatar kookster avatar franckverrot avatar joevandyk avatar godfat avatar xwmx avatar karthikc avatar

Watchers

 avatar Dharmarth Shah avatar  avatar Anand avatar Sunit Parekh avatar Aditya avatar Mohit Thatte avatar Priyank Gupta avatar Piyush Nimbalkar avatar Prasanna Kanagasabai avatar Harun avatar Aarti Kriplani avatar Ketan Soni avatar Arjun Khandelwal avatar Atreyee avatar Rishi Dahiya avatar Rohit Garg avatar  avatar Ginette Vellera avatar Jamie Monserrate avatar  avatar Suganthi avatar Sneha avatar  avatar Peter Morris avatar  avatar James Cloos avatar Rajashree Malvade avatar Sanchit Bahal avatar Bharti Nagpal avatar Adrian Jackson avatar Jesal Mistry avatar  avatar Pragya Jain avatar vatsal avatar Inderpal Singh avatar  avatar Vivek Chaturvedi avatar G avatar  avatar Mark Mather avatar Robbie avatar Jonathan avatar Stuart Curran avatar  avatar Football Pools Dev Pair avatar  avatar Michal Klesinski avatar Kuldeep Ghogre avatar  avatar Paul Gibbons avatar  avatar  avatar  avatar Gaurav avatar  avatar Priyanka Kapur avatar Adinath Shirsath avatar Ashwin Venkatesh avatar Sunny Aggarwal avatar Arshneet Singh avatar  avatar Vishnu Narang avatar Manan avatar  avatar Sumedha Verma avatar kriti mehta avatar Sumit avatar Dhanesh Arole avatar  avatar Priyanka Pathak avatar Khushbu avatar Aasawaree Deshmukh avatar MANJYOT SINGH avatar  avatar Pulkit Kochar avatar Riya Kataria avatar Vishal Sharma avatar Ravi Sharma avatar Kush Jain avatar Harshad Wankhede avatar  avatar Srujana avatar Ruchi Mutneja avatar  avatar Shweta Dongare avatar Digvijay Gunjal avatar Kavita Jadhav avatar Chirag Aggarwal avatar  avatar Sourabh Ghorpade avatar  avatar  avatar Abhinav Tiwary avatar  avatar Amandeep Singh avatar Abhishek Puri avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.