From 4346de02cf42edf994ec6d62a326924ebf7e90e1 Mon Sep 17 00:00:00 2001 From: Cory Lown Date: Mon, 9 Jun 2025 12:32:03 -0400 Subject: [PATCH] Index names on components so search works as expected (#1613) --- lib/arclight/traject/ead2_component_config.rb | 1 + spec/features/fielded_search_results_spec.rb | 4 ++++ spec/features/highlighted_search_results_spec.rb | 4 ++-- spec/features/traject/ead2_indexing_spec.rb | 4 ++++ spec/fixtures/ead/sul-spec/a0011.xml | 3 +++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/arclight/traject/ead2_component_config.rb b/lib/arclight/traject/ead2_component_config.rb index 64c17d0d3..ac164ae02 100644 --- a/lib/arclight/traject/ead2_component_config.rb +++ b/lib/arclight/traject/ead2_component_config.rb @@ -268,6 +268,7 @@ NAME_ELEMENTS.map do |selector| to_field 'names_ssim', extract_xpath("./controlaccess/#{selector}"), unique + to_field 'names_ssim', extract_xpath(".//#{selector}"), unique to_field "#{selector}_ssim", extract_xpath(".//#{selector}") end diff --git a/spec/features/fielded_search_results_spec.rb b/spec/features/fielded_search_results_spec.rb index 3ce6c8089..2f920848b 100644 --- a/spec/features/fielded_search_results_spec.rb +++ b/spec/features/fielded_search_results_spec.rb @@ -87,6 +87,10 @@ it '#name' do visit search_catalog_path q: 'root', search_field: 'name' within('.document-position-1') do + expect(page).to have_css '.index_title', text: /Dr. Root and L. Raymond Higgins/ + end + + within('.document-position-2') do expect(page).to have_css '.index_title', text: /Alpha Omega Alpha Archives/ end end diff --git a/spec/features/highlighted_search_results_spec.rb b/spec/features/highlighted_search_results_spec.rb index d323fda71..0b067cb97 100644 --- a/spec/features/highlighted_search_results_spec.rb +++ b/spec/features/highlighted_search_results_spec.rb @@ -29,8 +29,8 @@ visit search_catalog_path q: 'william root', search_field: 'name' within '.document-position-1' do within '.al-document-highlight' do - expect(page).to have_css 'em', text: 'William', count: 3 - expect(page).to have_css 'em', text: 'Root', count: 3 + expect(page).to have_css 'em', text: 'William', count: 1 + expect(page).to have_css 'em', text: 'Root', count: 2 end end end diff --git a/spec/features/traject/ead2_indexing_spec.rb b/spec/features/traject/ead2_indexing_spec.rb index e97407d01..8ca54f775 100644 --- a/spec/features/traject/ead2_indexing_spec.rb +++ b/spec/features/traject/ead2_indexing_spec.rb @@ -176,6 +176,10 @@ def components(result) ) end + it 'names' do + expect(first_component['names_ssim']).to include 'Stanford, Leland' + end + it 'geogname' do %w[geogname_ssim geogname_ssm].each do |field| expect(all_components.first[field]).to be_nil diff --git a/spec/fixtures/ead/sul-spec/a0011.xml b/spec/fixtures/ead/sul-spec/a0011.xml index 09f77cb89..9ad136ad2 100644 --- a/spec/fixtures/ead/sul-spec/a0011.xml +++ b/spec/fixtures/ead/sul-spec/a0011.xml @@ -177,6 +177,9 @@ 1 + + Stanford, Leland +