Sha256: 4dd7d33de1de8aa27f0a08ae5a0b2401c34ef5ec828d0eb396647e200696d4b2

Contents?: true

Size: 844 Bytes

Versions: 22

Compression:

Stored size: 844 Bytes

Contents

module Spotlight
  module SolrDocument
    ##
    # Solr indexing strategy using Solr's Atomic Updates
    module AtomicUpdates
      def reindex
        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

      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

22 entries across 22 versions & 1 rubygems

Version Path
blacklight-spotlight-0.14.2 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.14.1 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.14.0 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.13.0 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.12.1 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.12.0 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.11.0 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.10.3 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.10.2 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.10.1 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.10.0 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.9.2 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.9.1 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.9.0 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.8.2 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.8.1 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.8.0 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.7.2 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.7.1 app/models/concerns/spotlight/solr_document/atomic_updates.rb
blacklight-spotlight-0.7.0 app/models/concerns/spotlight/solr_document/atomic_updates.rb