Class RDig::Index::Indexer
In: lib/rdig/index.rb
Parent: Object

used by the crawler to build the ferret index

Methods

<<   add_to_index   close   new  

Included Modules

MonitorMixin

Public Class methods

[Source]

    # File lib/rdig/index.rb, line 8
 8:       def initialize(settings)
 9:         @config = settings
10:         @index_writer = Ferret::Index::IndexWriter.new(
11:                           :path     => settings.path,
12:                           :create   => settings.create,
13:                           :analyzer => settings.analyzer)
14:         super() # scary, MonitorMixin won't initialize if we don't call super() here (parens matter)
15:       end

Public Instance methods

<<(document)

Alias for add_to_index

[Source]

    # File lib/rdig/index.rb, line 17
17:       def add_to_index(document)
18:         puts "add to index: #{document.uri.to_s}" if RDig::config.verbose
19:         @config.rewrite_uri.call(document.uri) if @config.rewrite_uri
20:         # all stored and tokenized, should be ferret defaults
21:         doc = { 
22:           :url   => document.uri.to_s,
23:           :title => document.title,
24:           :data  => document.body
25:         }
26:         synchronize do
27:           @index_writer << doc
28:         end
29:       end

[Source]

    # File lib/rdig/index.rb, line 32
32:       def close
33:         @index_writer.optimize
34:         @index_writer.close
35:         @index_writer = nil
36:       end

[Validate]