Skip to content

Commit

Permalink
Fix: Inconsistent null count in tissue atlas term facet (#6458, PR #6482
Browse files Browse the repository at this point in the history
)
  • Loading branch information
achave11-ucsc committed Aug 16, 2024
2 parents c55e152 + 8485142 commit 3cc586a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/azul/service/elasticsearch_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def _prepare_aggregation(self, *, facet: str, facet_path: FieldPath) -> Agg:
agg_type='terms',
field=path,
size=config.terms_aggregation_size)
agg.bucket('untagged', 'missing', field=path)
nested_agg.bucket('untagged', 'missing', field=path)
return agg

def _annotate_aggs_for_translation(self, request: Search):
Expand Down Expand Up @@ -369,7 +369,7 @@ def _flatten_nested_aggs(self, aggs: MutableJSON):
except KeyError:
pass
else:
agg['myTerms'] = nested_agg['myTerms']
agg.update(nested_agg)

def _translate_response_aggs(self, aggs: MutableJSON):
"""
Expand Down
8 changes: 5 additions & 3 deletions test/service/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -3498,11 +3498,13 @@ def test_projects_response(self):
self.assertEqual(expected_bionetwork_name, project['bionetworkName'])
self.assertTrue(project['isTissueAtlasProject'])

tissue_atlas = {
tissue_atlas = response_json['termFacets']['tissueAtlas']
self.assertEqual(5, tissue_atlas['total'])
terms = {
entry['term']: entry['count']
for entry in response_json['termFacets']['tissueAtlas']['terms']
for entry in tissue_atlas['terms']
}
self.assertEqual({None: 1, 'Lung': 1, 'Retina': 1, 'Blood': 1}, tissue_atlas)
self.assertEqual({None: 2, 'Lung': 1, 'Retina': 1, 'Blood': 1}, terms)


class TestUnpopulatedIndexResponse(IndexResponseTestCase):
Expand Down

0 comments on commit 3cc586a

Please sign in to comment.