Fixed project search
The project ID wasn't used at all when searching in a project's context.
This commit is contained in:
@@ -55,7 +55,7 @@ def nested_bool(must: list, should: list, terms: dict, *, index_alias: str) -> S
|
||||
return search
|
||||
|
||||
|
||||
def do_node_search(query: str, terms: dict, page: int) -> dict:
|
||||
def do_node_search(query: str, terms: dict, page: int, project_id: str='') -> dict:
|
||||
"""
|
||||
Given user query input and term refinements
|
||||
search for public published nodes
|
||||
@@ -73,6 +73,8 @@ def do_node_search(query: str, terms: dict, page: int) -> dict:
|
||||
]
|
||||
|
||||
must = []
|
||||
if project_id:
|
||||
must.append({'term': {'project.id': project_id}})
|
||||
|
||||
if not query:
|
||||
should = []
|
||||
|
@@ -42,10 +42,11 @@ def _page_index() -> int:
|
||||
@blueprint_search.route('/')
|
||||
def search_nodes():
|
||||
searchword = request.args.get('q', '')
|
||||
project_id = request.args.get('project', '')
|
||||
terms = _term_filters()
|
||||
page_idx = _page_index()
|
||||
|
||||
result = queries.do_node_search(searchword, terms, page_idx)
|
||||
result = queries.do_node_search(searchword, terms, page_idx, project_id)
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user