From 6e6605268ff284f076c9bcceccc03bb72358a0a0 Mon Sep 17 00:00:00 2001 From: Alberto Islas Date: Mon, 6 Jan 2025 12:35:53 -0600 Subject: [PATCH] fix(search): Avoid additional lookups for valid_decay_relevance_types --- cl/lib/elasticsearch_utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cl/lib/elasticsearch_utils.py b/cl/lib/elasticsearch_utils.py index d08d3e675d..c39292e9aa 100644 --- a/cl/lib/elasticsearch_utils.py +++ b/cl/lib/elasticsearch_utils.py @@ -2607,10 +2607,11 @@ def apply_custom_score_to_main_query( main_order_by == "score desc" and cd["type"] in valid_decay_relevance_types ): - date_field = str(valid_decay_relevance_types[cd["type"]]["field"]) - scale = int(valid_decay_relevance_types[cd["type"]]["scale"]) - decay = float(valid_decay_relevance_types[cd["type"]]["decay"]) - min_score = float(valid_decay_relevance_types[cd["type"]]["min_score"]) + decay_settings = valid_decay_relevance_types[cd["type"]] + date_field = str(decay_settings["field"]) + scale = int(decay_settings["scale"]) + decay = float(decay_settings["decay"]) + min_score = float(decay_settings["min_score"]) query = build_decay_relevance_score( query, date_field,