Skip to content

Commit e78f750

Browse files
authored
Merge pull request #350 from MITLibraries/use-362
Exclude source from displayed highlights
2 parents 8bc124d + 3abeba8 commit e78f750

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

app/helpers/search_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
module SearchHelper
22
# These fields are used to filter out highlights that are already displayed in the main result view. Keep in mind these values need to be the names of fields in TIMDEX, not the normalized record keys.
3+
# Source is included because the selected search tab indicates the source.
34
def displayed_fields
45
['title', 'title.exact_value', 'content_type', 'dates.value', 'contributors.value', 'summary', 'citation',
5-
'subjects.value']
6+
'subjects.value', 'source']
67
end
78

89
def trim_highlights(result)

test/helpers/search_helper_test.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ class SearchHelperTest < ActionView::TestCase
88
{ 'matchedField' => 'title.exact_value', 'matchedPhrases' => 'Very important data' },
99
{ 'matchedField' => 'content_type', 'matchedPhrases' => 'Dataset' },
1010
{ 'matchedField' => 'dates.value', 'matchedPhrases' => '2022' },
11-
{ 'matchedField' => 'contributors.value', 'matchedPhrases' => 'Jane Datascientist' }] }
11+
{ 'matchedField' => 'contributors.value', 'matchedPhrases' => 'Jane Datascientist' },
12+
{ 'matchedField' => 'source', 'matchedPhrases' => 'mit archivesspace' }] }
1213
assert_empty trim_highlights(result)
1314
end
1415

@@ -21,7 +22,8 @@ class SearchHelperTest < ActionView::TestCase
2122
result = { highlight: [{ 'matchedField' => 'title', 'matchedPhrases' => 'Very important data' },
2223
{ 'matchedField' => 'content_type', 'matchedPhrases' => 'Dataset' },
2324
{ 'matchedField' => 'numbering', 'matchedPhrases' => '2022' },
24-
{ 'matchedField' => 'notes', 'matchedPhrases' => 'Datascientist, Jane' }] }
25+
{ 'matchedField' => 'notes', 'matchedPhrases' => 'Datascientist, Jane' },
26+
{ 'matchedField' => 'source', 'matchedPhrases' => 'mit archivesspace' }] }
2527
assert_equal [{ 'matchedField' => 'numbering', 'matchedPhrases' => '2022' },
2628
{ 'matchedField' => 'notes', 'matchedPhrases' => 'Datascientist, Jane' }], trim_highlights(result)
2729
end

0 commit comments

Comments
 (0)