Skip to content

Commit

Permalink
Fix query build
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Nov 18, 2024
1 parent a3af448 commit 3a14b25
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions app/commons/log_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

from app.utils import text_processing

FIELDS_TO_CLEAN = ["message", "detected_message", "detected_message_with_numbers", "stacktrace",
"detected_message_extended", "stacktrace_extended", "message_extended",
"message_without_params_extended", "message_without_params_and_brackets",
FIELDS_TO_CLEAN = ["message", "detected_message", "detected_message_with_numbers", "detected_message_extended",
"message_extended", "message_without_params_extended", "message_without_params_and_brackets",
"detected_message_without_params_and_brackets"]
FIELDS_TO_MERGE = ["message", "found_exceptions", "potential_status_codes", "found_tests_and_methods", "only_numbers",
"urls", "paths", "message_params", "detected_message_without_params_extended", "whole_message"]
Expand Down Expand Up @@ -63,9 +62,9 @@ def merge_big_and_small_logs(
fields_to_clean=FIELDS_TO_CLEAN)
log_ids_for_merged_logs[merged_logs_id] = logs_ids_in_merged_logs[log_level]
for field in log_level_messages:
if field in ["message"]:
if field == "message":
continue
if field in ["whole_message"]:
if field == "whole_message":
new_log["_source"][field] = log_level_messages[field][log_level]
else:
new_log["_source"][field] = text_processing.compress(
Expand Down Expand Up @@ -122,7 +121,7 @@ def decompose_logs_merged_and_without_duplicates(

for field in log_level_messages:
if field in log["_source"]:
splitter = "\n" if field in ["message", "whole_message"] else " "
splitter = "\n" if field in {"message", "whole_message"} else " "
log_level_messages[field][log_level] = \
log_level_messages[field][log_level] + log["_source"][field] + splitter

Expand Down
4 changes: 2 additions & 2 deletions app/commons/log_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def _fill_common_fields(log_template: dict, log: Log, prepared_log: PreparedLogM
log_template["_source"]["stacktrace"] = prepared_log.stacktrace
log_template["_source"]["potential_status_codes"] = prepared_log.exception_message_potential_status_codes
log_template["_source"]["found_exceptions"] = prepared_log.exception_found
log_template["_source"]["whole_message"] = (prepared_log.exception_message_no_params + "\n"
+ prepared_log.stacktrace)
log_template["_source"]["whole_message"] = '\n'.join([prepared_log.exception_message_no_params,
prepared_log.stacktrace])


def _fill_log_fields(log_template: dict, log: Log, number_of_lines: int) -> dict[str, Any]:
Expand Down
4 changes: 2 additions & 2 deletions app/service/cluster_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self, app_config: ApplicationConfig, search_cfg: SearchConfig):

def add_query_with_start_time_decay(self, main_query: dict[str, Any]) -> dict[str, Any]:
return {
"_source": main_query["_source"],
"size": main_query["size"],
"query": {
"function_score": {
Expand Down Expand Up @@ -73,8 +74,7 @@ def build_search_similar_items_query(
min_should_match: str = "95%") -> dict[str, Any]:
"""Build search query"""
query = {
"_source": ["whole_message", "test_item", "is_merged",
"detected_message", "stacktrace", "launch_id", "cluster_id",
"_source": ["whole_message", "test_item", "is_merged", "detected_message", "launch_id", "cluster_id",
"cluster_message", "potential_status_codes", "found_exceptions"],
"size": 10,
"query": {
Expand Down

0 comments on commit 3a14b25

Please sign in to comment.