From dc40190cca67ee51ac85697d2b4408c9922752c7 Mon Sep 17 00:00:00 2001 From: liuwenping Date: Fri, 13 May 2022 19:11:16 +0800 Subject: [PATCH] =?UTF-8?q?minor:=20=E7=AC=AC=E4=B8=89=E6=96=B9es=EF=BC=8C?= =?UTF-8?q?=E9=80=9A=E8=BF=87index=5Fset=5Fid=E8=8E=B7=E5=8F=96time=5Ffiel?= =?UTF-8?q?d=EF=BC=8C=E9=A6=96=E5=85=88=E4=BB=8E=E5=AD=90index=E4=B8=AD?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=EF=BC=8C=E5=AD=90index=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E5=86=8D=E4=BB=8E?= =?UTF-8?q?index=5Fset=E6=9C=AC=E8=BA=AB=E8=8E=B7=E5=8F=96=EF=BC=8C?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E5=86=8D=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/log_esquery/serializers.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/log_esquery/serializers.py b/apps/log_esquery/serializers.py index 86f5b6a4b..c426263ff 100644 --- a/apps/log_esquery/serializers.py +++ b/apps/log_esquery/serializers.py @@ -369,10 +369,13 @@ def _init_index_info(*, index_set_id): index = [x.get("result_table_id", None) for x in index_set_data_obj_list] indices = ",".join(index) if scenario_id not in [Scenario.BKDATA, Scenario.LOG]: - time_field_list = [x.get("time_field", None) for x in index_set_data_obj_list] - if len(time_field_list) > 0: - time_field = time_field_list[0] - else: + time_field = None + for x in index_set_data_obj_list: + time_field = x.get("time_field") + if time_field: + break + time_field = time_field or tmp_index_obj.time_field + if time_field is None: raise BaseSearchIndexSetIdTimeFieldException( BaseSearchIndexSetIdTimeFieldException.MESSAGE.format(index_set_id=index_set_id) )