Skip to content

Commit

Permalink
Move URI filtering to Python instead of Virtuoso
Browse files Browse the repository at this point in the history
Virtuoso was locking up because of too many filter criterion.
  • Loading branch information
yu-eric committed Oct 19, 2021
1 parent dff2ed4 commit b783ab8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions flask/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,20 +607,21 @@ def search(sparql_query, uri2rank, clusters, default_graph_uri):
if 'file_search' in flags:
filename = str(flags['file_search'])
results = sequencesearch.sequence_search(flags, filename)
sequence_criteria = create_sequence_criteria(criteria, filter_sequence_search_subjects(_from, results))
criteria_response = query.query_parts(_from, sequence_criteria)
bindings = create_criteria_bindings(criteria_response, uri2rank, True, filename[:-4] + '.uc')
allowed_uris = filter_sequence_search_subjects(_from, results)
criteria_response = query.query_parts(_from)
# Filter searches by URI to hide private parts here instead of on Virtuoso
criteria_response_filtered = [c for c in criteria_response if any(f for f in allowed_uris if f in c.get('subject'))]
bindings = create_criteria_bindings(criteria_response_filtered, uri2rank, True, filename[:-4] + '.uc')

elif len(sequence.strip()) > 0:
# send sequence search to search.py
temp_filename = sequencesearch.write_to_temp(sequence)
results = sequencesearch.sequence_search(flags, temp_filename)

# return new clusters here
# pass into func -> queryparts create_sequence_criteria
sequence_criteria = create_sequence_criteria(criteria, filter_sequence_search_subjects(_from, results))
criteria_response = query.query_parts(_from, sequence_criteria)
bindings = create_criteria_bindings(criteria_response, uri2rank, True, temp_filename[:-4] + '.uc')
allowed_uris = filter_sequence_search_subjects(_from, results)
criteria_response = query.query_parts(_from)
criteria_response_filtered = [c for c in criteria_response if any(f for f in allowed_uris if f in c.get('subject'))]
bindings = create_criteria_bindings(criteria_response_filtered, uri2rank, True, temp_filename[:-4] + '.uc')

elif 'SIMILAR' in criteria:
# SIMILAR
Expand Down

0 comments on commit b783ab8

Please sign in to comment.