Sha256: 8e4a6fd63fd1af88e352c8f6231a59c3e3852e071ba5f3b7fb2c7c6bfd5d7a1b

Contents?: true

Size: 954 Bytes

Versions: 15

Compression:

Stored size: 954 Bytes

Contents

module Spotlight
  ##
  # Proxy update requests to Solr and inject spotlight's exhibit
  # specific fields.
  #
  # This is an example of how you could integrate external indexing
  # workflows with exhibit-specific content
  class SolrController < Spotlight::ApplicationController
    before_action :authenticate_user!
    before_action :validate_writable_index!

    load_and_authorize_resource :exhibit, class: Spotlight::Exhibit

    def update
      authorize! :update_solr, @exhibit

      req = ActiveSupport::JSON.decode(request.body.read)

      docs = Array.wrap(req).map do |r|
        blacklight_config.document_model.new(r).to_solr.merge(@exhibit.solr_data).merge(r)
      end

      blacklight_solr.update docs

      render nothing: true
    end

    private

    def validate_writable_index!
      return if Spotlight::Engine.config.writable_index

      render text: 'Spotlight is unable to write to solr', status: 409
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
blacklight-spotlight-0.23.0 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.22.0 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.21.0 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.20.3 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.20.2 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.20.1 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.20.0 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.19.2 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.19.1 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.19.0 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.18.0 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.17.1 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.17.0 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.16.0 app/controllers/spotlight/solr_controller.rb
blacklight-spotlight-0.15.0 app/controllers/spotlight/solr_controller.rb