Skip to content

Commit

Permalink
Merge pull request #56 from dbmi-pitt/karlburke/indexingEfficienciesR…
Browse files Browse the repository at this point in the history
…ound5

Leaves add_calculated_fields() unwanted fields on origin_samples[0] d…
  • Loading branch information
yuanzhou authored Jun 27, 2024
2 parents 21ce1dc + 8e5b244 commit 21f68a0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/opensearch_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,26 @@ def get_uuids_from_es(index, es_url):

def execute_opensearch_query(query_against, request, index, es_url, query=None, request_params=None):
supported_query_against = ['_search', '_count', '_mget']
supported_endpoints_with_id = ['_update']
supported_endpoints = supported_query_against + supported_endpoints_with_id
separator = ','

if query_against not in supported_query_against:
bad_request_error(
f"Query against '{query_against}' is not supported by Search API. Use one of the following: {separator.join(supported_query_against)}")
# If query_against has a / in it, assume a 32 character identifier after the / is okay, but
# verify the endpoint_base name before the / is in supported_query_against
if '/' in query_against:
endpoint_elements = query_against.split(sep='/'
,maxsplit=1)
# For an internal function like this, assume the 32 character part after the / is
# a UUID without verifying the format, and allow it through.
if endpoint_elements[0] not in supported_endpoints_with_id \
or len(endpoint_elements[1]) != 32:
bad_request_error(f"Query of endpoint '{endpoint_elements[0]}'"
f" with identifier '{endpoint_elements[1]}'"
" is not supported by Search API."
f" Supported endoints are: {separator.join(supported_endpoints)}")
elif query_against not in supported_query_against:
bad_request_error( f"Query against '{query_against}' is not supported by Search API."
f" Use one of the following: {separator.join(supported_endpoints)}")

# Determine the target real index in Elasticsearch to be searched against
# index = get_target_index(request, index_without_prefix)
Expand Down

0 comments on commit 21f68a0

Please sign in to comment.