From d12e30b648ca3d41777726181c940fc964fdc952 Mon Sep 17 00:00:00 2001 From: Alberto Islas Date: Fri, 22 Nov 2024 17:20:44 -0600 Subject: [PATCH] fix(api): Fixed score merge and improved related test --- cl/lib/elasticsearch_utils.py | 2 +- cl/tests/cases.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cl/lib/elasticsearch_utils.py b/cl/lib/elasticsearch_utils.py index 119f78a754..1b9366f713 100644 --- a/cl/lib/elasticsearch_utils.py +++ b/cl/lib/elasticsearch_utils.py @@ -3355,5 +3355,5 @@ def set_child_docs_and_score( merge_highlights_into_result(meta_hl, result) # Optionally merges the BM25 score for display in the API. - if merge_score and isinstance(result, Response): + if merge_score and isinstance(result, AttrDict): result["bm25_score"] = result.meta.score diff --git a/cl/tests/cases.py b/cl/tests/cases.py index 0b95c311e1..8b23dea418 100644 --- a/cl/tests/cases.py +++ b/cl/tests/cases.py @@ -270,6 +270,11 @@ async def _compare_field( set(meta_expected_value.keys()), f"The keys in field '{meta_field}' do not match.", ) + for score_value in meta_value.values(): + self.assertIsNotNone( + score_value, f"The score value can't be None." + ) + else: self.assertEqual( meta_value,