Giter Club home page Giter Club logo

pg_search_scope's Introduction

PG Search Scope ;

PostgreSQL full text search using Rails 3 scopes

Basic usage

Include gem pg_search_scope in your Gemfile

In model, use search_scope_for class method to create full text search scope.

Examples:

search_scope_for :name
-->
search_by_name("Ivan")

In migration, use add_fulltext_index / remove_fulltext_index the same way as add_index / remove_index

Advanced usage

You can set additional search options:

:as - Scope name

:normalization - Controls rank behaviour, see http://www.postgresql.org/docs/9.0/static/textsearch-controls.html#TEXTSEARCH-RANKING

:wildcard - Controls search words modification:
                 true - add :* to ends of each search word
                 false - do not modify search words
                 :last - add :* to end of last word

:operator - Boolean operator (:and or :or) which combines search query

:select_rank - Include rank in select statement, as {scope_name}_rank

:language - Search language, e.g. 'simple' (without magic), 'english'

:rank_function - Ranking function. Valid values  are  'ts_rank' and 'ts_rank_cd'

:rank_columns - If you want to sort table by rank only by specific fields - input column names here

If you use :language option, you need to use the same option for add_fulltext_index

Examples:

search_scope_for :name, :address,
                 :wildcard => :last
-->
search_by_name_and_address("Ivan, Aurora st.", :select_rank => true)

To do

...

Copyright

Copyright (c) 2011 Ivan Efremov, Ilia Ablamonov, Cloud Castle Inc. See LICENSE for details.

pg_search_scope's People

Contributors

flamefork avatar strikeroff avatar st8998 avatar kelion avatar deemkey avatar

Watchers

 avatar James Cloos 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.