Class: XapianDb::Indexer

Inherits:
Object
  • Object
show all
Defined in:
lib/xapian_db/indexer.rb

Overview

The indexer creates a Xapian::Document from an object. They object must be an instance of a class that has a blueprint configuration.

Author:

  • Gernot Kogler

Instance Method Summary collapse

Constructor Details

#initialize(database, document_blueprint) ⇒ Indexer

Constructor

Parameters:


13
14
15
# File 'lib/xapian_db/indexer.rb', line 13

def initialize(database, document_blueprint)
  @database, @document_blueprint = database, document_blueprint
end

Instance Method Details

#build_document_for(obj) ⇒ Xapian::Document

Build the document for an object. The object must respond to 'xapian_id'. The configured adapter should implement this method.

Returns:


20
21
22
23
24
25
26
27
28
# File 'lib/xapian_db/indexer.rb', line 20

def build_document_for(obj)
  @obj = obj
  @blueprint = DocumentBlueprint.blueprint_for(@obj.class.name)
  @xapian_doc = Xapian::Document.new
  @xapian_doc.data = @obj.xapian_id
  store_fields
  index_text
  @xapian_doc
end