Project

search_do

0.01
No commit activity in last 3 years
No release in over 3 years
AR: Hyperestraier integration
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project 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:

Install¶ ↑

As Rails plugin(recommended <-> rake tasks/cap recipes):

rails plugin install git://github.com/grosser/search_do.git

Or as Gem:

sudo gem install search_do

install will_paginate to use “paginate_by_fulltext_search” (Instruction: 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

TODO¶ ↑

- make specs work with RSpec 2

Origin¶ ↑

Original is written by scoop see