Fixed project search

The project ID wasn't used at all when searching in a project's context.
This commit is contained in:
2018-03-13 12:24:29 +01:00
parent 257793dcd5
commit df6297d40f
5 changed files with 31 additions and 32 deletions

View File

@@ -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 = []

View File

@@ -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)