T53161 Proof of Concept working USER search. WIP js.
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user