Created
January 7, 2010 02:38
-
-
Save rsinger/270920 to your computer and use it in GitHub Desktop.
Ruby script to check which MARC records are missing from a Solr index.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
# Be sure to have the latest version of rubygems and run: | |
# sudo gem install rsolr | |
# sudo gem install marc | |
require 'rsolr' | |
require 'marc' | |
# Set the following three vars to whatever applies locally. | |
solr = RSolr.connect :url=>'http://localhost:8080/solr' | |
marc_path = '/path/to/marc/files/' | |
skipped_marc_out = '/path/to/skipped_marc_out.mrc' | |
marc_out = MARC::Writer.new(skipped_marc_out) | |
Dir.open(marc_path).each do | file | | |
MARC::ForgivingReader.new(open("#{marc_path}#{file}")).each do | record | | |
ctrl = record['001'].value | |
response = solr.select :q=>"id:#{ctrl}" | |
unless response['response']['numFound'] > 0 | |
marc_out.write(record) | |
end | |
end | |
end | |
marc_out.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment