-
Library for fulltext search integration with active record.
-
Build to support multiple search Backends
-
acts_as_searchable Successor
A working Hyper Estraier instance, setup instructions:
-
Setup Instructions: pragmatig.wordpress.com/2008/05/06/getting-started-with-acts_as_searchable-on-ubuntu/
-
In-depth Documentation: hyperestraier.sourceforge.net/nguide-en.html
-
rake search:node:create MODEL=User RAILS_ENV=production - for every model/environment you use
As Rails plugin(recommended <-> rake tasks/cap recipes):
script/plugin install git://github.com/grosser/search_do.git
Or as Gem:
sudo gem install searh_do
install will_paginate to use “paginate_by_fulltext_search” (Instruction: github.com/mislav/will_paginate/wikis/installation)
#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.
- Phrase search, regular expressions, attribute search, and similarity search - Snippet retrival - UTF8 support - Web interface - Built in P2P clustering of index servers
Original is written by scoop see