Skip to content

Commit

Permalink
restructure geocombine:index to issue solr.update for each record in …
Browse files Browse the repository at this point in the history
…multi-record geoblacklight.json files
  • Loading branch information
Darren Hardy committed Dec 15, 2017
1 parent f575cc4 commit 8b5e7d3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/tasks/geo_combine.rake
Expand Up @@ -28,16 +28,19 @@ namespace :geocombine do

desc 'Index all of the GeoBlacklight JSON documents'
task :index do
solr = RSolr.connect :url => solr_url
solr = RSolr.connect url: solr_url
puts "Indexing #{ogm_path} into #{solr_url}"
Dir.glob("#{ogm_path}/**/geoblacklight.json") do |path|
doc = JSON.parse(File.read(path))
begin
solr.update params: { commitWithin: commit_within, overwrite: true },
data: [doc].flatten.to_json,
headers: { 'Content-Type' => 'application/json' }

rescue RSolr::Error::Http => error
puts error
[doc].flatten.each do |record|
begin
puts "Indexing #{record['layer_slug_s']}: #{path}" if $DEBUG
solr.update params: { commitWithin: commit_within, overwrite: true },
data: [record].to_json,
headers: { 'Content-Type' => 'application/json' }
rescue RSolr::Error::Http => error
puts error
end
end
end
solr.commit
Expand Down

0 comments on commit 8b5e7d3

Please sign in to comment.