Admin user search: boost user ID matching

This commit is contained in:
Sybren A. Stüvel 2018-01-05 16:02:49 +01:00
parent 01d8ad5ca2
commit af69b4fa58

View File

@ -129,7 +129,12 @@ def do_user_search_admin(query: str) -> dict:
# We most likely got and id field. we should find it. # We most likely got and id field. we should find it.
if len(query) == len('563aca02c379cf0005e8e17d'): if len(query) == len('563aca02c379cf0005e8e17d'):
should.append(Q('term', objectID=query)) should.append({'term': {
'objectID': {
'value': query, # the thing we're looking for
'boost': 100, # how much more it counts for the score
}
}})
search = Search(using=client) search = Search(using=client)
search.query = Q('bool', should=should) search.query = Q('bool', should=should)