Created
January 6, 2010 18:00
-
-
Save rsinger/270474 to your computer and use it in GitHub Desktop.
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' | |
require 'rdf_objects' | |
require 'rsolr' | |
require 'open-uri' | |
# "apache-solr" should be a path to a solr build. | |
Dir['apache-solr/dist/*.jar'].each{|jar|require jar} | |
Dir['apache-solr/lib/*.jar'].each{|jar|require jar} | |
opts = {:home_dir=>'/path/to/solr/home'} | |
Curie.add_prefixes! :skos=>"http://www.w3.org/2004/02/skos/core#" | |
collection = RDFObject::Parser.parse(open('http://www.ukat.org.uk/downloads/skos.rdf').read)) | |
RSolr.direct_connect opts do |solr| | |
collection.each do | uri, obj | | |
doc = obj.skos | |
doc[:uri] = uri | |
solr.add doc | |
end | |
solr.commit | |
solr.optimize | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment