

def bulk_fetch_results(self, paginated_results):
    "\n        This method gets paginated search results and returns a list of Django\n        objects in the same order.\n\n        It preserves the order without doing any ordering in Python, even\n        when more than one Django model are returned in the search results. It\n        also uses the same queryset that was used to populate the search\n        queryset, so any select_related/prefetch_related optimisations are\n        in effect.\n\n        It is heavily based on Haystack's SearchQuerySet.post_process_results,\n        but works on the paginated results instead of all of them.\n        "
    objects = []
    models_pks = loaded_objects = {
        
    }
    for result in paginated_results:
        models_pks.setdefault(result.model, []).append(result.pk)
    search_backend_alias = self.results.query.backend.connection_alias
    for model in models_pks:
        ui = connections[search_backend_alias].get_unified_index()
        index = ui.get_index(model)
        queryset = index.read_queryset(using=search_backend_alias)
        loaded_objects[model] = queryset.in_bulk(models_pks[paginated_results])
    for result in paginated_results:
        model_objects = loaded_objects.get(result.model, {
            
        })
        try:
            result._object = model_objects[int(result.pk)]
        except KeyError:
            pass
        else:
            objects.append(result._object)
    return objects

dataset/ETHPy150Open django-oscar/django-oscar/src/oscar/apps/search/search_handlers.py SearchHandler.bulk_fetch_results/VarMisuse@116/384 `model`->`paginated_results`