public
Fork of moro/search_do
Description: AR: Hyperestraier integration
Homepage:
Clone URL: git://github.com/grosser/search_do.git
grosser (author)
Sat Jan 17 00:49:59 -0800 2009
commit  ca31ae6215d74cde1f05c1a9f7f6d391022924cd
tree    47921598bd2f06efb0165d358d3760dc7fdcd3f5
parent  34eaaa29aac7643a51a769bcc503c58fd0c43b64
search_do / README
100755 63 lines (46 sloc) 2.285 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
= 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