Module: SearchDo

Defined in:
lib/search_do.rb,
lib/search_do/utils.rb,
lib/search_do/indexer.rb,
lib/search_do/backends.rb,
lib/search_do/dirty_tracking.rb,
lib/search_do/backends/hyper_estraier.rb

Overview

Specify this act if you want to provide fulltext search capabilities to your model via Hyper Estraier. This assumes a setup and running Hyper Estraier node accessible through the HTTP API provided by the EstraierPure Ruby module (which is bundled with this plugin).

The act supplies appropriate hooks to insert, update and remove documents from the index when you update your model data, create new objects or remove them from your database. For the initial indexing a convenience class method reindex! is provided.

Example:

class Article < ActiveRecord::Base
  attr_accessor :snippet
  acts_as_searchable
end

Article.reindex!

As soon as your model data has been indexed you can make use of the fulltext_search class method to search the index and get back instantiated matches.

results = Article.fulltext_search('rails')
results.size        # => 3

results.first.class # => Article
results.first.body  # => "Ruby on Rails is an open-source web framework"

Connectivity configuration can be either inherited from conventions or setup globally in the Rails database configuration file config/database.yml.

Example:

development:
  adapter: mysql
  database: rails_development
  host: localhost
  user: root
  password:
  estraier:
    host: localhost
    user: admin
    password: admin
    port: 1978
    node: development

That way you can configure separate connections for each environment. The values shown above represent the defaults. If you don’t need to change any of these it is safe to not specify the estraier hash at all.

See SearchDo::ClassMethods#acts_as_searchable for per-model configuration options

Defined Under Namespace

Modules: Backends, ClassMethods, DirtyTracking, InstanceMethods Classes: Indexer, Utils

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



82
83
84
# File 'lib/search_do.rb', line 82

def self.included(base) #:nodoc:
  base.extend ClassMethods
end