Skip to content

Commit

Permalink
Search person variant name
Browse files Browse the repository at this point in the history
Support search via person variant name as raised at
[#63](#63)
  • Loading branch information
paluchas committed Oct 15, 2020
1 parent 672aace commit 8c53647
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8c53647

Please sign in to comment.