app/models/spotlight/resource.rb in blacklight-spotlight-1.0.0 vs app/models/spotlight/resource.rb in blacklight-spotlight-1.1.0
- old
+ new
@@ -78,13 +78,15 @@
def batch_size
Spotlight::Engine.config.solr_batch_size
end
def write_to_index(batch)
- return unless write?
+ documents = documents_that_have_ids(batch)
+ return unless write? && documents.present?
+
blacklight_solr.update params: { commitWithin: 500 },
- data: batch.to_json,
+ data: documents.to_json,
headers: { 'Content-Type' => 'application/json' }
end
def commit
return unless write?
@@ -97,9 +99,13 @@
exhibit.touch
end
def write?
Spotlight::Engine.config.writable_index
+ end
+
+ def documents_that_have_ids(document_list)
+ document_list.reject { |d| d[document_builder.document_model.unique_key.to_sym].blank? }
end
end
end
end