diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index dea6ed2..f93a938 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -19,14 +19,23 @@ def index @search_array = [] # Get Concepts for the Person ConceptScheme and filter according to search_term - num = SolrQuery.new.solr_query(q = 'has_model_ssim:Person', fl = 'id', rows = 0)['response']['numFound'] - SolrQuery.new.solr_query(q = 'has_model_ssim:Person', fl = 'id, preflabel_tesim', rows = num, sort = 'preflabel_si asc')['response']['docs'].map.each do |result| + num = SolrQuery.new.solr_query(q = 'has_model_ssim:Person', + fl = 'id', + rows = 0)['response']['numFound'] + search_response = SolrQuery.new.solr_query(q = 'has_model_ssim:Person', + fl = 'id, preflabel_tesim, altlabel_tesim', + rows = num, + sort = 'preflabel_si asc') + search_response['response']['docs'].map.each do |result| id = result['id'] preflabel = result['preflabel_tesim'].join - + # Some persons do not have variant name + altlabel = '' + altlabel = result['altlabel_tesim'].join unless result['altlabel_tesim'].nil? tt = [] - next unless preflabel.match(/#{@search_term}/i) + # Select results that match person name or person variant name + next unless preflabel.match(/#{@search_term}/i) || altlabel.match(/#{@search_term}/i) tt << id tt << preflabel