BO news via ES #5 (optimize)
This commit is contained in:
parent
aab99af87f
commit
affb985b15
|
|
@ -186,7 +186,8 @@ class NewsQuerySet(TranslationQuerysetMixin):
|
|||
_query |= elasticsearch_dsl.Q('wildcard', **{key: {'value': f'*{search_value}*', 'boost': boost + 30}})
|
||||
search = NewsDocument.search().query('bool', should=_query)[0:10000].execute()
|
||||
ids = [result.meta.id for result in search]
|
||||
preserved = Case(*[When(pk=pk, then=pos) for pos, pk in enumerate(ids)])
|
||||
ids_order = enumerate(ids)
|
||||
preserved = Case(*[When(pk=pk, then=pos) for pos, pk in ids_order])
|
||||
return self.filter(id__in=ids).order_by(preserved)
|
||||
|
||||
def trigram_search(self, search_value: str):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user