Skip to content

Commit

Permalink
fix project file search bug, added search on project id
Browse files Browse the repository at this point in the history
  • Loading branch information
shayanaijaz committed Oct 18, 2023
1 parent 6326cae commit f7c473c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions server/portal/apps/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ def get(self, request):
search = IndexedProject.search()

ngram_query = Q("query_string", query=query_string,
fields=["title"],
fields=["title", "id"],
minimum_should_match='100%',
default_operator='or')

wildcard_query = Q("wildcard", title=f'*{query_string}*')
wildcard_query = Q("wildcard", title=f'*{query_string}*') | Q("wildcard", id=f'*{query_string}*')

search = search.query(ngram_query | wildcard_query)
search = search.extra(from_=int(offset), size=int(limit))
Expand Down
2 changes: 1 addition & 1 deletion server/portal/libs/agave/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def search(client, system, path='', offset=0, limit=100, query_string='', filter
if filter:
search = search.filter(filter_query)

search = search.filter('prefix', **{'path._exact': path})
search = search.filter('prefix', **{'path._exact': path.strip('/')})
search = search.filter('term', **{'system._exact': system})
search = search.extra(from_=int(offset), size=int(limit))
res = search.execute()
Expand Down
2 changes: 1 addition & 1 deletion server/portal/libs/elasticsearch/docs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


class IndexedProject(Document):
id = Keyword()
id = Keyword(fields={'_exact': Keyword()})
title = Text(fields={'_exact': Keyword()})
description = Text()
path = Text()
Expand Down
2 changes: 0 additions & 2 deletions server/portal/libs/elasticsearch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ def index_listing(files):
file_dict = dict(_file)
if file_dict['name'][0] == '.':
continue
if not file_dict['path'].startswith('/'):
file_dict['path'] = '/' + file_dict['path']
file_dict['lastUpdated'] = current_time()
file_dict['basePath'] = os.path.dirname(file_dict['path'])
file_uuid = file_uuid_sha256(file_dict['system'], file_dict['path'])
Expand Down

0 comments on commit f7c473c

Please sign in to comment.