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



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

def delete(druid)
  solr_targets_configs = BaseIndexer.solr_configuration_class_name.constantize.instance.get_configuration_hash
  BaseIndexer.solr_writer_class_name.constantize.new.solr_delete_from_all(druid, solr_targets_configs)
end

#index(druid, targets = nil) ⇒ Object

It is the main indexing function

Raises:

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



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

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
  solr_targets_configs = BaseIndexer.solr_configuration_class_name.constantize.instance.get_configuration_hash
  BaseIndexer.solr_writer_class_name.constantize.new.process(druid, solr_doc, targets, solr_targets_configs)
end