T53161 Proof of Concept working USER search. WIP js.

This commit is contained in:
2017-11-17 16:05:22 +01:00
parent 76bb68dcc8
commit b03e8d5bd7
8 changed files with 200 additions and 18 deletions

View File

@@ -42,3 +42,44 @@ def do_search(query: str) -> dict:
response = search.execute()
return response.to_dict()
def do_user_search(query: str) -> dict:
"""
return user objects
"""
should = [
Q('match', username=query),
Q('match', full_name=query),
]
bool_query = Q('bool', should=should)
search = Search(using=client)
search.query = bool_query
if current_app.config['DEBUG']:
log.debug(json.dumps(search.to_dict(), indent=4))
response = search.execute()
return response.to_dict()
def do_user_search_admin(query: str) -> dict:
"""
return users with all fields and aggregations
"""
should = [
Q('match', username=query),
Q('match', email=query),
Q('match', full_name=query),
]
bool_query = Q('bool', should=should)
search = Search(using=client)
search.query = bool_query
if current_app.config['DEBUG']:
log.debug(json.dumps(search.to_dict(), indent=4))
response = search.execute()
return response.to_dict()