Skip to content

Commit

Permalink
Add an indexed solr field for which exhibits an object appears in
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer authored and Jessie Keck committed Dec 18, 2017
1 parent a41e428 commit 2ac31c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/models/concerns/spotlight/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def sidecar(exhibit)
end

def to_solr
{ self.class.unique_key.to_sym => id }.reverse_merge(sidecars.inject({}) { |acc, elem| acc.merge(elem.to_solr) }).merge(tags_to_solr)
{ self.class.unique_key.to_sym => id }.reverse_merge(sidecars.inject({}) { |acc, elem| acc.merge(elem.to_solr) })
.merge(tags_to_solr)
.merge(exhibits_to_solr)
end

def make_public!(exhibit)
Expand Down Expand Up @@ -128,6 +130,14 @@ def tags_to_solr
end
h
end

def exhibits_to_solr
slugs = sidecars.map(&:exhibit).map(&:slug)

{
"#{Spotlight::Engine.config.solr_fields.prefix}spotlight_exhibit_slugs#{Spotlight::Engine.config.solr_fields.string_suffix}" => slugs
}
end
end
end

Expand Down
5 changes: 5 additions & 0 deletions spec/services/spotlight/solr_document_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
expect(result).to include "spotlight_exhibit_slug_#{resource_alt.exhibit.slug}_bsi"
end

it 'has a field with both exhibit slugs listed' do
result = resource.document_builder.documents_to_index.first
expect(result).to include 'spotlight_exhibit_slugs_ssim' => match_array([resource.exhibit.slug, resource_alt.exhibit.slug])
end

it 'creates a sidecar resource for the document' do
resource.document_builder.documents_to_index.first

Expand Down

0 comments on commit 2ac31c1

Please sign in to comment.