diff --git a/app/service/analyzer_service.py b/app/service/analyzer_service.py index 660fea93..f0649fe8 100644 --- a/app/service/analyzer_service.py +++ b/app/service/analyzer_service.py @@ -70,23 +70,23 @@ def add_constraints_for_launches_into_query(self, query: dict, launch) -> dict: # Previous launches with the same name must = self.create_path(query, ('query', 'bool', 'must'), []) must_not = self.create_path(query, ('query', 'bool', 'must_not'), []) - must.append({'term': {'launch_name': {'value': launch_name}}}) - must_not.append({'term': {'launch_id': {'value': launch_id}}}) + must.append({'term': {'launch_name': launch_name}}) + must_not.append({'term': {'launch_id': launch_id}}) elif analyzer_mode == 'CURRENT_AND_THE_SAME_NAME': # All launches with the same name must = self.create_path(query, ('query', 'bool', 'must'), []) should = self.create_path(query, ('query', 'bool', 'should'), []) - must.append({'term': {'launch_name': {'value': launch_name}}}) + must.append({'term': {'launch_name': launch_name}}) should.append({'term': {'launch_id': {'value': launch_id, 'boost': launch_boost}}}) elif analyzer_mode == 'CURRENT_LAUNCH': # Just current launch must = self.create_path(query, ('query', 'bool', 'must'), []) - must.append({'term': {'launch_id': {'value': launch_id}}}) + must.append({'term': {'launch_id': launch_id}}) elif analyzer_mode == 'PREVIOUS_LAUNCH': # Just previous launch if previous_launch_id: must = self.create_path(query, ('query', 'bool', 'must'), []) - must.append({'term': {'launch_id': {'value': previous_launch_id}}}) + must.append({'term': {'launch_id': previous_launch_id}}) else: # Just all launches # Boost launches with the same name, but do not ignore any diff --git a/test_res/fixtures/query_all_logs_nonempty_stacktrace_launches_with_the_same_name.json b/test_res/fixtures/query_all_logs_nonempty_stacktrace_launches_with_the_same_name.json index 94d3737d..fc84ff7b 100644 --- a/test_res/fixtures/query_all_logs_nonempty_stacktrace_launches_with_the_same_name.json +++ b/test_res/fixtures/query_all_logs_nonempty_stacktrace_launches_with_the_same_name.json @@ -15,13 +15,11 @@ {"wildcard": {"issue_type": "ti*"}}, {"wildcard": {"issue_type": "nd*"}}, {"term": {"test_item": "123"}}, - {"term": {"launch_id": {"value": 12}}} + {"term": {"launch_id": 12}} ], "must": [ {"term": { - "launch_name": { - "value": "Launch name" - } + "launch_name": "Launch name" }}, {"more_like_this": { "fields": ["detected_message"], diff --git a/test_res/fixtures/query_analyze_items_including_no_defect.json b/test_res/fixtures/query_analyze_items_including_no_defect.json index 817c256a..dd094c54 100644 --- a/test_res/fixtures/query_analyze_items_including_no_defect.json +++ b/test_res/fixtures/query_analyze_items_including_no_defect.json @@ -13,16 +13,15 @@ ], "must_not": [ {"term": {"issue_type": "ti001"}}, - {"term": {"test_item": "123"}} + {"term": {"test_item": "123"}}, + {"term": {"launch_id": 12}} ], "must": [ {"term": { "test_case_hash": 1 }}, {"term": { - "launch_name": { - "value": "Launch name" - } + "launch_name": "Launch name" }}, {"more_like_this": { "fields": ["message"], @@ -52,7 +51,7 @@ "boost": 8.0 }} ], - "should": [{"term": {"launch_id": {"boost": 5, "value": 12}}}] + "should": [] } }, "functions": [ diff --git a/test_res/fixtures/query_analyze_items_including_no_defect_small_logs.json b/test_res/fixtures/query_analyze_items_including_no_defect_small_logs.json index 3da4d95e..22138373 100644 --- a/test_res/fixtures/query_analyze_items_including_no_defect_small_logs.json +++ b/test_res/fixtures/query_analyze_items_including_no_defect_small_logs.json @@ -14,6 +14,7 @@ "must_not": [ {"term": {"issue_type": "ti001"}}, {"term": {"test_item": "123"}}, + {"term": {"launch_id": 12}}, {"wildcard": {"message": "*"}} ], "must": [ @@ -21,9 +22,7 @@ "test_case_hash": 1 }}, {"term": { - "launch_name": { - "value": "Launch name" - } + "launch_name": "Launch name" }}, {"more_like_this": { "fields": ["merged_small_logs"], @@ -44,7 +43,7 @@ "boost": 8.0 }} ], - "should": [{"term": {"launch_id": {"boost": 5, "value": 12}}}] + "should": [] } }, "functions": [ diff --git a/test_res/fixtures/query_merged_small_logs_search.json b/test_res/fixtures/query_merged_small_logs_search.json index 71e34c76..a2f883a6 100644 --- a/test_res/fixtures/query_merged_small_logs_search.json +++ b/test_res/fixtures/query_merged_small_logs_search.json @@ -50,6 +50,12 @@ "boost": 10 } }}, + {"term": { + "launch_id": { + "value": 12, + "boost": 5 + } + }}, {"term": { "launch_name": { "value": "Launch name", diff --git a/test_res/fixtures/query_two_log_lines.json b/test_res/fixtures/query_two_log_lines.json index ffc35799..4730d84e 100644 --- a/test_res/fixtures/query_two_log_lines.json +++ b/test_res/fixtures/query_two_log_lines.json @@ -49,6 +49,12 @@ "boost": 10 } }}, + {"term": { + "launch_id": { + "value": 12, + "boost": 5 + } + }}, {"term": { "launch_name": { "value": "Launch name", diff --git a/test_res/fixtures/query_two_log_lines_only_current_launch.json b/test_res/fixtures/query_two_log_lines_only_current_launch.json index d146b005..45b244c5 100644 --- a/test_res/fixtures/query_two_log_lines_only_current_launch.json +++ b/test_res/fixtures/query_two_log_lines_only_current_launch.json @@ -18,9 +18,7 @@ ], "must": [ {"term": { - "launch_id": { - "value": 12 - } + "launch_id": 12 }}, {"more_like_this": { "fields": ["message"], diff --git a/test_res/fixtures/query_two_log_lines_only_current_launch_wo_exceptions.json b/test_res/fixtures/query_two_log_lines_only_current_launch_wo_exceptions.json index 198378da..68051e9f 100644 --- a/test_res/fixtures/query_two_log_lines_only_current_launch_wo_exceptions.json +++ b/test_res/fixtures/query_two_log_lines_only_current_launch_wo_exceptions.json @@ -18,9 +18,7 @@ ], "must": [ {"term": { - "launch_id": { - "value": 12 - } + "launch_id": 12 }}, {"more_like_this": { "fields": ["message"], diff --git a/test_res/fixtures/suggest_query_all_logs_empty_stacktrace.json b/test_res/fixtures/suggest_query_all_logs_empty_stacktrace.json index 6a9d2589..b7e6ed6f 100644 --- a/test_res/fixtures/suggest_query_all_logs_empty_stacktrace.json +++ b/test_res/fixtures/suggest_query_all_logs_empty_stacktrace.json @@ -40,6 +40,7 @@ "boost": 10 } }}, + {"term": {"launch_id": {"boost": 5, "value": 12}}}, {"term": { "launch_name": { "value": "Launch name", diff --git a/test_res/fixtures/suggest_query_all_logs_nonempty_stacktrace.json b/test_res/fixtures/suggest_query_all_logs_nonempty_stacktrace.json index 20fee51f..a70afe9b 100644 --- a/test_res/fixtures/suggest_query_all_logs_nonempty_stacktrace.json +++ b/test_res/fixtures/suggest_query_all_logs_nonempty_stacktrace.json @@ -48,6 +48,7 @@ "boost": 10 } }}, + {"term": {"launch_id": {"boost": 5, "value": 12}}}, {"term": { "launch_name": { "value": "Launch name", diff --git a/test_res/fixtures/suggest_query_all_logs_nonempty_stacktrace_launches_with_the_same_name.json b/test_res/fixtures/suggest_query_all_logs_nonempty_stacktrace_launches_with_the_same_name.json index 272a79e8..0abf4889 100644 --- a/test_res/fixtures/suggest_query_all_logs_nonempty_stacktrace_launches_with_the_same_name.json +++ b/test_res/fixtures/suggest_query_all_logs_nonempty_stacktrace_launches_with_the_same_name.json @@ -16,11 +16,6 @@ {"term": {"test_item": "123"}} ], "must": [ - {"term": { - "launch_name": { - "value": "Launch name" - } - }}, {"more_like_this": { "fields": ["detected_message_without_params_extended"], "like": "hello world", @@ -62,7 +57,8 @@ "boost": 10 } }}, - {"term": {"launch_id": {"boost": 5, "value": 12}}}, + {"term": {"launch_name": {"boost": 5, "value": "Launch name"}}}, + {"term": {"launch_id": {"boost": 0.2, "value": 12}}}, {"more_like_this": { "fields": ["merged_small_logs"], "like": "", diff --git a/test_res/fixtures/suggest_query_merged_small_logs_search.json b/test_res/fixtures/suggest_query_merged_small_logs_search.json index f4d7ccf8..ff2e7fce 100644 --- a/test_res/fixtures/suggest_query_merged_small_logs_search.json +++ b/test_res/fixtures/suggest_query_merged_small_logs_search.json @@ -49,6 +49,7 @@ "boost": 10 } }}, + {"term": {"launch_id": {"boost": 5, "value": 12}}}, {"term": { "launch_name": { "value": "Launch name", diff --git a/test_res/fixtures/suggest_query_two_log_lines.json b/test_res/fixtures/suggest_query_two_log_lines.json index 62d3fc91..40d155f2 100644 --- a/test_res/fixtures/suggest_query_two_log_lines.json +++ b/test_res/fixtures/suggest_query_two_log_lines.json @@ -48,6 +48,7 @@ "boost": 10 } }}, + {"term": {"launch_id": {"boost": 5, "value": 12}}}, {"term": { "launch_name": { "value": "Launch name",