Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to disable automatic commit after each resource is added to Solr. #7

Open
wants to merge 4 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/solrizer/fedora/indexer.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/solrizer/fedora/repository.rb
Expand Up @@ -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

#
Expand Down
11 changes: 10 additions & 1 deletion lib/solrizer/fedora/solrizer.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down