Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HYACINTH-1054 (2.5.x branch): Add ability to search by DOI value (as part of Identifiers search dropdown field) #450

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading