From 01d8ad5ca296503ed315b45d027c67d258e59a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 5 Jan 2018 15:52:25 +0100 Subject: [PATCH] Admin user search: also match on user ID And removed user ID matching for regular user search. --- pillar/api/search/queries.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pillar/api/search/queries.py b/pillar/api/search/queries.py index 8a60118e..527f9d8b 100644 --- a/pillar/api/search/queries.py +++ b/pillar/api/search/queries.py @@ -99,10 +99,6 @@ def do_user_search(query: str, terms: dict) -> dict: Q('term', _type='user') ] - # We most likely got and id field. we MUST find it. - if len(query) == len('563aca02c379cf0005e8e17d'): - must.append(Q('term', _id=query)) - if not query: should = [] @@ -130,9 +126,13 @@ def do_user_search_admin(query: str) -> dict: Q('match', email=query), Q('match', full_name=query), ] - bool_query = Q('bool', should=should) + + # We most likely got and id field. we should find it. + if len(query) == len('563aca02c379cf0005e8e17d'): + should.append(Q('term', objectID=query)) + search = Search(using=client) - search.query = bool_query + search.query = Q('bool', should=should) if log.isEnabledFor(logging.DEBUG): log.debug(json.dumps(search.to_dict(), indent=4))