public
Fork of moro/search_do
Description: AR: Hyperestraier integration
Homepage:
Clone URL: git://github.com/grosser/search_do.git
name age message
file CHANGELOG Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
file MIT-LICENSE Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
file README Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
file Rakefile Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
file TESTING Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
file TODO Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
directory examples/ Mon Jan 05 06:04:48 -0800 2009 some examples [grosser]
file init.rb Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
file install.rb Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
directory lib/ Mon Jan 05 05:51:27 -0800 2009 empty order -> no order set [grosser]
directory rails/ Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
directory recipes/ Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
directory spec/ Tue Jan 06 01:37:35 -0800 2009 tested date ordering [grosser]
directory tasks/ Sat Jan 17 00:49:59 -0800 2009 stop loading env when not needed [grosser]
directory test/ Mon Dec 29 03:00:02 -0800 2008 mode-change on all files... + more documentation [grosser]
README
= search_do
* Library for fulltext search integration with active record.
* Build to support multiple search Backends
* acts_as_searchable Successor


== Pre-requisites
A working Hyper Estraier instance, setup instructions:

* Setup Instructions: http://pragmatig.wordpress.com/2008/05/06/getting-started-with-acts_as_searchable-on-ubuntu/
* In-depth Documentation: http://hyperestraier.sourceforge.net/nguide-en.html
* rake search:node:create MODEL=User RAILS_ENV=production - for every model/environment you use


== Install
* script/plugin install git://github.com/grosser/search_do.git
* install will_paginate to use "paginate_by_fulltext_search" (Instruction: 
http://github.com/mislav/will_paginate/wikis/installation)


== Usage

  #MODEL
  class User < ActiveRecord::Base
    acts_as_searchable(
      #fields the will be found in fulltext search
      :searchable_fields => [:name,:website,:city,:about],
      #fields used for attribute search/ordering
      :attributes => {:name=>nil,:city=>nil,:country=>nil,:age=>nil}
    )
    attr_accessor :html_snippet #add this to get html snippets on your results (see below)
  end

  #SEARCH
  Users who:
   - contain 'hello' in any of their searchable fields
   - whose website attribute contains 'www' (contains search for strings)
   - whose age is 1 (exact match for numbers/dates)
   - sorted by age ASC
  @results = User.paginate_by_fulltext_search('hello',:attributes=>{:website=>'www',:age=>1},:order=>'age 
  ASC',:page=>1,:per_page=>20)

  (Same can be done without pagination: User.fulltext_search)

  #SNIPPETS
  Each record found with a fulltext-search (not a attribute-only search) contains a snippet
  of the surrounding where the phrase was found.

  User.fulltext_search('hello') => user.html_snippet == "id like to say <b>hello</b> to my fellow students"

  NOTE: html_snippet will not contain HTML except for the <b>, so there is no need to escape it.


== Hyperestraier Features
 - Phrase search, regular expressions, attribute search, and similarity search
 - Snippet retrival
 - UTF8 support
 - Web interface
 - Built in P2P clustering of index servers


== Origin
Original is written by scoop see
* http://github.com/scoop/acts_as_searchable/tree/master
* http://poocs.net/2006/4/6/introducing-acts-as-searchable