diff --git a/swirl/processors/mapping.py b/swirl/processors/mapping.py index 4b561dfc5..5de5fa5a7 100644 --- a/swirl/processors/mapping.py +++ b/swirl/processors/mapping.py @@ -53,10 +53,13 @@ def process(self): json_types = [str,int,float,list,dict] use_payload = True file_system = False + event = False if 'NO_PAYLOAD' in self.provider.result_mappings: use_payload = False if 'FILE_SYSTEM' in self.provider.result_mappings: file_system = True + if 'EVENT' in self.provider.result_mappings: + event = True result_number = 1 for result in self.results: @@ -270,6 +273,8 @@ def process(self): # mark results from SearchProviders with result_mapping FILE_SYSTEM if file_system: swirl_result['_relevancy_model'] = 'FILE_SYSTEM' + if event: + swirl_result['_relevancy_model'] = 'EVENT' swirl_result['searchprovider'] = self.provider.name list_results.append(swirl_result) result_number = result_number + 1 diff --git a/swirl/processors/relevancy.py b/swirl/processors/relevancy.py index 2b99e3b14..5e0d6328c 100644 --- a/swirl/processors/relevancy.py +++ b/swirl/processors/relevancy.py @@ -410,6 +410,7 @@ def process(self): relevancy_model = item['_relevancy_model'] del item['_relevancy_model'] fs_flag_boost_body = False + fs_flag_boost_title = False if relevancy_model: if relevancy_model == 'FILE_SYSTEM': # if title has no matches, and body does, copy body to title; delete it from explain @@ -419,6 +420,14 @@ def process(self): if len(item['body']) > 0: # match on body, none on title -> use title boost on body fs_flag_boost_body = True + if relevancy_model == 'EVENT': + # if body has no matches, and title does, use 2 x title; delete it from explain + if not 'body' in dict_score: + # no matches on body + if 'title' in dict_score: + if len(item['title']) > 0: + # match on title, none on body -> use title boost x2 + fs_flag_boost_title= True # score the item dict_len_adjust = {} for f in dict_score: @@ -430,6 +439,12 @@ def process(self): weight = RELEVANCY_CONFIG['title']['weight'] else: self.warning(f"title field missing when applying relevancy model: FILE_SYSTEM") + if f == 'title': + if fs_flag_boost_title: + if 'title' in RELEVANCY_CONFIG: + weight = RELEVANCY_CONFIG['title']['weight'] * 2.0 + else: + self.warning(f"title field missing when applying relevancy model: EVENT") else: continue len_adjust = float(dict_len_median[f] / dict_len[f]) diff --git a/swirl/swirl_common.py b/swirl/swirl_common.py index 694093006..0e65665be 100644 --- a/swirl/swirl_common.py +++ b/swirl/swirl_common.py @@ -1,4 +1,4 @@ """ A place for defs share beteween connectors and processors """ -RESULT_MAPPING_COMMANDS = [ 'NO_PAYLOAD', 'FILE_SYSTEM', 'LC_URL' ] \ No newline at end of file +RESULT_MAPPING_COMMANDS = [ 'NO_PAYLOAD', 'FILE_SYSTEM', 'EVENT', 'LC_URL' ] \ No newline at end of file