Skip to content

Commit

Permalink
Merge pull request #449 from cul/2.6.x-HYACINTH-1054
Browse files Browse the repository at this point in the history
HYACINTH-1054 (2.6.x branch): Add ability to search by DOI value (as part of Identifiers search dropdown field)
  • Loading branch information
elohanlon authored Jul 25, 2024
2 parents 6e424a1 + e78c922 commit 851ae86
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def to_solr

doc[:search_identifier_sim] << pid
doc[:search_identifier_sim].push(*identifiers) # Also append all identifiers to the array
doc[:search_identifier_sim] << self.doi.sub(/^doi:/, '') if self.doi.present? # Also append DOI to the array
doc[:search_keyword_teim] << pid

if flattened_dynamic_field_data.present?
Expand Down
27 changes: 27 additions & 0 deletions spec/models/concerns/digital_object/index_and_search/index_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'rails_helper'

describe DigitalObject::IndexAndSearch::Index do
let(:pid) { 'cul:12345' }
let(:identifiers) { ['id1', 'id2'] }
let(:doi) { 'doi:10.7916/sa43-bk43' }
let(:doi_without_prefix) { doi.gsub(/^doi:/, '') }
let(:project) { Project.new(display_label: 'Sample Project') }
let(:digital_object) {
DigitalObject::Item.new.tap do |obj|
obj.identifiers = identifiers
obj.doi = doi
allow(obj).to receive(:pid).and_return(pid)
allow(obj).to receive(:project).and_return(project)
end
}

let(:solr_doc) { digital_object.to_solr }

describe '#to_solr' do
context 'search_identifier_sim field' do
it 'sets the expected values' do
expect(solr_doc[:search_identifier_sim]).to eq([pid] + identifiers + [doi_without_prefix])
end
end
end
end

0 comments on commit 851ae86

Please sign in to comment.