app/models/spotlight/solr_document_sidecar.rb in blacklight-spotlight-0.3.1 vs app/models/spotlight/solr_document_sidecar.rb in blacklight-spotlight-0.4.1

- old
+ new

@@ -26,11 +26,11 @@ def document_type (super.constantize if defined?(super)) || default_document_type end def default_document_type - blacklight_config.solr_document_model + blacklight_config.document_model end protected def visibility_field @@ -40,9 +40,28 @@ def blacklight_config exhibit.blacklight_config end def data_to_solr - Hash[data.map { |k,v| [k,v] }] + data.except("configured_fields").merge(configured_fields_data_to_solr) end + + def configured_fields_data_to_solr + solr_hash = {} + if data["configured_fields"] + configured_fields = Spotlight::Resources::Upload.fields(exhibit) + + configured_fields.each do |field| + solr_fields = Array(field.solr_field || field.field_name) + if data["configured_fields"][field.field_name.to_s].present? + solr_fields.each do |solr_field| + solr_hash[solr_field] = data["configured_fields"][field.field_name.to_s] + end + end + end + end + + solr_hash.select { |k,v| v.present? } + end + end end