diff --git a/lib/solrizer/fedora/indexer.rb b/lib/solrizer/fedora/indexer.rb index 96266c8..ccf902d 100644 --- a/lib/solrizer/fedora/indexer.rb +++ b/lib/solrizer/fedora/indexer.rb @@ -174,10 +174,15 @@ def create_document( obj ) # This method adds a document to the Solr search index # def index( obj ) + index( obj, true ) + end + def index( obj, autocommit ) solr.add( create_document( obj ) ) + solr.commit if autocommit + end + def commit solr.commit end - private :connect diff --git a/lib/solrizer/fedora/repository.rb b/lib/solrizer/fedora/repository.rb index 4735623..76be602 100644 --- a/lib/solrizer/fedora/repository.rb +++ b/lib/solrizer/fedora/repository.rb @@ -19,7 +19,7 @@ def self.get_pids( num_docs ) # This method retrieves the object associated with the given unique id # def self.get_object( pid ) - object = ActiveFedora::Base.find( pid ) + object = ActiveFedora::Base.find( pid, :cast => true ) end # diff --git a/lib/solrizer/fedora/solrizer.rb b/lib/solrizer/fedora/solrizer.rb index 04bd05a..bff3164 100644 --- a/lib/solrizer/fedora/solrizer.rb +++ b/lib/solrizer/fedora/solrizer.rb @@ -57,7 +57,12 @@ def solrize( obj, opts={} ) logger.debug "\t Indexing object #{obj.pid} ... " # add the keywords and facets to the search index index_start = Time.now - indexer.index( obj ) + if opts[:autocommit] != nil + autocommit = opts[:autocommit] + else + autocommit = true + end + indexer.index( obj, autocommit ) index_done = Time.now index_elapsed = index_done - index_start @@ -74,6 +79,10 @@ def solrize( obj, opts={} ) end end + + def commit + indexer.commit + end # Retrieve a comprehensive list of all the unique identifiers in Fedora and # solrize each object's full-text and facets into the search index