Class: Solrizer::Solrizer
- Inherits:
-
Object
- Object
- Solrizer::Solrizer
- Defined in:
- lib/solrizer.rb
Instance Attribute Summary collapse
-
#index_full_text ⇒ Object
Returns the value of attribute index_full_text.
-
#indexer ⇒ Object
Returns the value of attribute indexer.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Solrizer
constructor
This method initializes the indexer If passed an argument of :index_full_text=>true, it will perform full-text indexing instead of indexing fields only.
-
#solrize(obj) ⇒ Object
This method solrizes the given Fedora object’s full-text and facets into the search index.
-
#solrize_objects ⇒ Object
This method retrieves a comprehensive list of all the unique identifiers in Fedora and solrizes each object’s full-text and facets into the search index.
Constructor Details
#initialize(opts = {}) ⇒ Solrizer
This method initializes the indexer If passed an argument of :index_full_text=>true, it will perform full-text indexing instead of indexing fields only.
21 22 23 24 25 26 27 28 29 |
# File 'lib/solrizer.rb', line 21 def initialize( opts={} ) @@index_list = false unless defined?(@@index_list) if opts[:index_full_text] == true || opts[:index_full_text] == "true" @index_full_text = true else @index_full_text = false end @indexer = Indexer.new( :index_full_text=>@index_full_text ) end |
Instance Attribute Details
#index_full_text ⇒ Object
Returns the value of attribute index_full_text.
15 16 17 |
# File 'lib/solrizer.rb', line 15 def index_full_text @index_full_text end |
#indexer ⇒ Object
Returns the value of attribute indexer.
15 16 17 |
# File 'lib/solrizer.rb', line 15 def indexer @indexer end |
Instance Method Details
#solrize(obj) ⇒ Object
This method solrizes the given Fedora object’s full-text and facets into the search index
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/solrizer.rb', line 34 def solrize( obj ) # retrieve the Fedora object based on the given unique id begin start = Time.now print "Retrieving object #{obj} ..." case obj when ActiveFedora::Base # do nothing when Fedora::FedoraObject obj = Repository.get_object( obj.pid ) when String obj = Repository.get_object( obj ) else raise "you must pass either a ActiveFedora::Base, Fedora::RepositoryObject, or a String. You submitted a #{obj.class}" end # obj = obj.kind_of?(ActiveFedora::Base) ? obj : Repository.get_object( obj ) obj_done = Time.now obj_done_elapse = obj_done - start puts " completed. Duration: #{obj_done_elapse}" print "\t Indexing object #{obj.pid} ... " # add the keywords and facets to the search index index_start = Time.now indexer.index( obj ) index_done = Time.now index_elapsed = index_done - index_start puts "completed. Duration: #{index_elapsed} ." rescue Exception => e p "unable to index #{obj}. Failed with #{e.inspect}" end #begin end |
#solrize_objects ⇒ Object
This method retrieves a comprehensive list of all the unique identifiers in Fedora and solrizes each object’s full-text and facets into the search index
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/solrizer.rb', line 81 def solrize_objects # retrieve a list of all the pids in the fedora repository num_docs = 1000000 # modify this number to guarantee that all the objects are retrieved from the repository puts "WARNING: You have turned off indexing of Full Text content. Be sure to re-run indexer with @@index_full_text set to true in main.rb" if index_full_text == false if @@index_list == false objects = Fedora::Repository.instance.find_objects(:limit=>num_docs) puts "Shelving #{objects.length} Fedora objects" objects.each do |object| solrize( object ) end else if File.exists?(@@index_list) arr_of_pids = FasterCSV.read(@@index_list, :headers=>false) puts "Indexing from list at #{@@index_list}" puts "Shelving #{arr_of_pids.length} Fedora objects" arr_of_pids.each do |row| pid = row[0] solrize( pid ) end #FASTERCSV else puts "#{@@index_list} does not exists!" end #if File.exists end #if Index_LISTS end |