From dfeb88890270be29ac7417d5eaf04b1f34786366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esm=C3=A9=20Cowles?= Date: Mon, 27 Jan 2014 15:26:05 -0500 Subject: [PATCH 1/4] Removing automatic commit and adding explit commit method --- lib/solrizer/fedora/indexer.rb | 4 ++++ lib/solrizer/fedora/solrizer.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/solrizer/fedora/indexer.rb b/lib/solrizer/fedora/indexer.rb index 96266c8..e919a32 100644 --- a/lib/solrizer/fedora/indexer.rb +++ b/lib/solrizer/fedora/indexer.rb @@ -175,6 +175,10 @@ def create_document( obj ) # def index( obj ) solr.add( create_document( obj ) ) + #solr.commit + logger.warn "not committing" + end + def commit solr.commit end diff --git a/lib/solrizer/fedora/solrizer.rb b/lib/solrizer/fedora/solrizer.rb index 04bd05a..704ff64 100644 --- a/lib/solrizer/fedora/solrizer.rb +++ b/lib/solrizer/fedora/solrizer.rb @@ -74,6 +74,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 From a8f46ec0eaac937afc1bd1f1a60f96bf6176e540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esm=C3=A9=20Cowles?= Date: Mon, 27 Jan 2014 19:36:36 -0500 Subject: [PATCH 2/4] Enabling auto-commit by default (DHH-300) --- lib/solrizer/fedora/indexer.rb | 5 ++--- lib/solrizer/fedora/solrizer.rb | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/solrizer/fedora/indexer.rb b/lib/solrizer/fedora/indexer.rb index e919a32..3292d99 100644 --- a/lib/solrizer/fedora/indexer.rb +++ b/lib/solrizer/fedora/indexer.rb @@ -173,10 +173,9 @@ def create_document( obj ) # # This method adds a document to the Solr search index # - def index( obj ) + def index( obj, autocommit ) solr.add( create_document( obj ) ) - #solr.commit - logger.warn "not committing" + solr.commit if autocommit end def commit solr.commit diff --git a/lib/solrizer/fedora/solrizer.rb b/lib/solrizer/fedora/solrizer.rb index 704ff64..2c1486e 100644 --- a/lib/solrizer/fedora/solrizer.rb +++ b/lib/solrizer/fedora/solrizer.rb @@ -57,7 +57,9 @@ 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 ) + commit = opts[:autocommit] + commit ||= true + indexer.index( obj, commit ) index_done = Time.now index_elapsed = index_done - index_start From 906dd51eb5606821650598eeff5471909145cfe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esm=C3=A9=20Cowles?= Date: Tue, 28 Jan 2014 11:21:31 -0500 Subject: [PATCH 3/4] Adding index method with old signature (DHH-300) --- lib/solrizer/fedora/indexer.rb | 4 +++- lib/solrizer/fedora/solrizer.rb | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/solrizer/fedora/indexer.rb b/lib/solrizer/fedora/indexer.rb index 3292d99..ccf902d 100644 --- a/lib/solrizer/fedora/indexer.rb +++ b/lib/solrizer/fedora/indexer.rb @@ -173,6 +173,9 @@ 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 @@ -180,7 +183,6 @@ def index( obj, autocommit ) def commit solr.commit end - private :connect diff --git a/lib/solrizer/fedora/solrizer.rb b/lib/solrizer/fedora/solrizer.rb index 2c1486e..bff3164 100644 --- a/lib/solrizer/fedora/solrizer.rb +++ b/lib/solrizer/fedora/solrizer.rb @@ -57,9 +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 - commit = opts[:autocommit] - commit ||= true - indexer.index( obj, commit ) + 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 From 87c2d35e89df19bb4535e1f713a68b0dc469498a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esm=C3=A9=20Cowles?= Date: Tue, 11 Feb 2014 10:14:58 -0500 Subject: [PATCH 4/4] Fixing AF 6.7 deprecation warning re: ActiveFedora::Base.find() without :cast parameter (DHH-305) --- lib/solrizer/fedora/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 #