Skip to content

Commit

Permalink
don't try to match up non-string values
Browse files Browse the repository at this point in the history
stopgap fix for #151
  • Loading branch information
wkdewey committed Dec 16, 2024
1 parent ae7f0a8 commit f5b61b4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/services/search_item_res.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def combine_highlights

def find_source_from_top_hits(top_hits, field, key)
# elasticsearch stores nested source results without the "path"

parent = field.split(".").first
if field.include?(".")
nested_child = field.split(".").last
Expand Down Expand Up @@ -124,15 +125,18 @@ def reformat_facets
end

def remove_nonword_chars(term)

if term.class == Array
#ensure that term is a string value, not an array
term = term[0]
end
# transliterate to ascii (ø -> o)
transliterated = I18n.transliterate(term)
# remove html tags like em, u, and strong, then strip remaining non-alpha characters
transliterated.gsub(/<\/?(?:em|strong|u)>|\W/, "").downcase
if term.class == String
# it should not be a hash, but this is a failsafe
# transliterate to ascii (ø -> o)
transliterated = I18n.transliterate(term)
# remove html tags like em, u, and strong, then strip remaining non-alpha characters
transliterated.gsub(/<\/?(?:em|strong|u)>|\W/, "").downcase
end
end

def get_buckets(info, field)
Expand Down

0 comments on commit f5b61b4

Please sign in to comment.