Sha256: 6e6ed03a2694a6a5c8d2c7cede3e301fdf6a67d23e21d1a8c043e6f06994e739
Contents?: true
Size: 949 Bytes
Versions: 43
Compression:
Stored size: 949 Bytes
Contents
module Spotlight module SolrDocument ## # Solr indexing strategy using Solr's Atomic Updates module AtomicUpdates def reindex return unless write? data = hash_for_solr_update(to_solr) blacklight_solr.update params: { commitWithin: 500 }, data: data.to_json, headers: { 'Content-Type' => 'application/json' } unless data.empty? end def write? Spotlight::Engine.config.writable_index end private def hash_for_solr_update(data) Array.wrap(data).map { |doc| convert_document_to_atomic_update_hash(doc) }.reject { |x| x.length <= 1 } end def convert_document_to_atomic_update_hash(doc) doc.each_with_object({}) do |(k, v), hash| hash[k] = if k.to_sym == self.class.unique_key.to_sym v else { set: v } end end end end end end
Version data entries
43 entries across 43 versions & 1 rubygems