Skip to content

Commit

Permalink
remove expensive prefix filter from Elasticsearch file queries (#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarosenb authored Dec 16, 2024
1 parent b358988 commit 8aa9fb4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions designsafe/apps/api/datafiles/operations/tapis_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,13 @@ def search(client, system, path, offset=0, limit=100, query_string='', **kwargs)

if not path.startswith('/'):
path = '/' + path
if not path.endswith('/'):
path = path + '/'

path = f"/{path.strip('/')}"

search = IndexedFile.search()
search = search.query(ngram_query | match_query)
search = search.filter('prefix', **{'path._exact': path})
if path != '/':
search = search.filter('term', **{'path._comps': path})
search = search.filter('term', **{'system._exact': system})
search = search.extra(from_=int(offset), size=int(limit))
res = search.execute()
Expand Down Expand Up @@ -219,7 +221,7 @@ def mkdir(client, system, path, dir_name, *args, **kwargs):
-------
dict
"""
path_input = str(Path(path) / Path(dir_name))
path_input = str(Path(path) / Path(dir_name)).rstrip(" ")
client.files.mkdir(systemId=system, path=path_input)


Expand Down

0 comments on commit 8aa9fb4

Please sign in to comment.