Fix search

This commit is contained in:
Robin Champenois 2021-06-28 23:29:58 +02:00
parent c40a91fb67
commit 26ad68ff69

View file

@ -158,13 +158,13 @@ def cherche(**kwargs):
resultat = Stage.objects.filter(filtres).distinct() resultat = Stage.objects.filter(filtres).distinct()
if USE_ELASTICSEARCH and use_dsl: if USE_ELASTICSEARCH and use_dsl:
dls_res = [s.meta.id for s in dsl.scan()[:50]] dsl_res = [s.meta.id for s in dsl.scan()]
resultat = resultat.filter(id__in=dsl_res) resultat = resultat.filter(id__in=dsl_res)
if tri == "pertinence": if tri == "pertinence":
resultat = resultat.order_by( resultat = resultat.order_by(
Case( Case(
*[When(pk=pk, then=pos) for pos, pk in enumerate(pks)] *[When(pk=pk, then=pos) for pos, pk in enumerate(dsl_res)]
) )
) )
else: else: