Class: Spotlight::SolrController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spotlight/solr_controller.rb

Overview

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

Instance Method Summary collapse

Methods included from Concerns::ApplicationController

#enabled_in_spotlight_view_type_configuration?, #field_enabled?

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #current_site, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #resource_masthead?, #search_action_url, #search_facet_url

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/spotlight/solr_controller.rb', line 14

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