Skip to content

Commit f8cc064

Browse files
committed
titleize bucket values because ES automatically lowercases them
1 parent 6e92258 commit f8cc064

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/services/search_item_res.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def find_source_from_top_hits(top_hits, field, key)
4949
if hit.class == Array
5050
# I don't love this, because we will have to match exactly the logic
5151
# that got us the key to get this to work
52-
match_index = hit
53-
.map { |s| remove_nonword_chars(s) }
54-
.index(remove_nonword_chars(key))
52+
match_index = hit
53+
.map { |s| remove_nonword_chars(s) }
54+
.index(remove_nonword_chars(key))
5555
# if nothing matches the original key, return the entire source hit
5656
# should return a string, regardless
5757
return match_index ? hit[match_index] : hit.join(" ")
@@ -64,7 +64,7 @@ def find_source_from_top_hits(top_hits, field, key)
6464
def format_bucket_value(facets, field, bucket)
6565
# dates return in wonktastic ways, so grab key_as_string instead of gibberish number
6666
# but otherwise just grab the key if key_as_string unavailable
67-
key = bucket.key?("key_as_string") ? bucket["key_as_string"] : bucket["key"]
67+
key = bucket.key?("key_as_string") ? bucket["key_as_string"].titleize : bucket["key"].titleize
6868
val = bucket.key?("field_to_item") ? bucket["field_to_item"]["doc_count"] : bucket["doc_count"]
6969
source = key
7070
# top_matches is a top_hits aggregation which returns a list of terms

0 commit comments

Comments
 (0)