Skip to content

Instantly share code, notes, and snippets.

@rsinger
Created January 6, 2010 18:00
Show Gist options
  • Save rsinger/270474 to your computer and use it in GitHub Desktop.
Save rsinger/270474 to your computer and use it in GitHub Desktop.
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