Class: BaseIndexer::MainIndexerEngine

Inherits:
Object
  • Object
show all
Includes:
DiscoveryIndexer
Defined in:
lib/base_indexer/main_indexer_engine.rb

Overview

It is responsible for performing the basic indexing steps, it includes reading the input from PURL server, getting collection names, mapping it to solr doc hash, and write it to SOLR core . It can also delete the object from all the registered

Examples:

Index with target list

indexer = BaseIndexer::MainIndexerEngine.new
indexer.index "ab123cd456", ["searchworks","revs"]

Index from release_tags

indexer = BaseIndexer::MainIndexerEngine.new
indexer.index "ab123cd456"

Delete item from all solr cores

indexer = BaseIndexer::MainIndexerEngine.new
indexer.delete "ab123cd456"

Instance Method Summary collapse

Instance Method Details

#delete(druid) ⇒ Object

It deletes an item defined by druid from all registered solr core

Parameters:

  • druid (String)

    is the druid for an object e.g., ab123cd4567



38
39
40
41
# File 'lib/base_indexer/main_indexer_engine.rb', line 38

def delete(druid)
  BaseIndexer.solr_writer_class_name.constantize.new
             .solr_delete_from_all(druid, Settings.SOLR_TARGETS.to_hash.deep_stringify_keys)
end

#index(druid, targets = nil) ⇒ Object

It is the main indexing function

Parameters:

  • druid (String)

    is the druid for an object e.g., ab123cd4567

  • targets (Array) (defaults to: nil)

    is an array with the targets list to index towards

Raises:

  • it will raise erros if there is any problems happen in any level



27
28
29
30
31
32
33
34
# File 'lib/base_indexer/main_indexer_engine.rb', line 27

def index(druid, targets = nil)
  # Map the input to solr_doc
  solr_doc = BaseIndexer.mapper_class_name.constantize.new(druid).convert_to_solr_doc

  # Get SOLR configuration and write
  BaseIndexer.solr_writer_class_name.constantize.new
             .process(druid, solr_doc, targets, Settings.SOLR_TARGETS.to_hash.deep_stringify_keys)
end