Skip to content

Add EVENT result_mapping which doubles titles for configured SPs DO NOT MERGE #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions swirl/processors/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions swirl/processors/relevancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion swirl/swirl_common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
A place for defs share beteween connectors and processors
"""
RESULT_MAPPING_COMMANDS = [ 'NO_PAYLOAD', 'FILE_SYSTEM', 'LC_URL' ]
RESULT_MAPPING_COMMANDS = [ 'NO_PAYLOAD', 'FILE_SYSTEM', 'EVENT', 'LC_URL' ]