diff --git a/socorro/external/es/supersearch.py b/socorro/external/es/supersearch.py index ed642a2702..6892ff740a 100644 --- a/socorro/external/es/supersearch.py +++ b/socorro/external/es/supersearch.py @@ -75,12 +75,12 @@ def get_indices(self, dates): def format_field_names(self, hit): """Return hit with field's search_key replaced with name""" - if not hit.keys(): - return {} - # unnest hit one level and update keys - namespace = one(hit) - hit = {f"{namespace}.{key}": item for key, item in hit[namespace].items()} + hit = { + f"{namespace}.{key}": item + for namespace in hit + for key, item in hit[namespace].items() + } new_hit = {} for field_name in self.request_columns: diff --git a/socorro/tests/external/es/test_supersearch.py b/socorro/tests/external/es/test_supersearch.py index 10056854c5..bfddc22e17 100644 --- a/socorro/tests/external/es/test_supersearch.py +++ b/socorro/tests/external/es/test_supersearch.py @@ -491,7 +491,8 @@ def test_get_with_bool_operators(self, es_helper): assert resp["total"] == 2 assert len(resp["hits"]) == 2 - assert not resp["hits"][0]["accessibility"] + for hit in resp["hits"]: + assert not hit["accessibility"] def test_get_with_combined_operators(self, es_helper): now = utc_now()