Skip to content

Commit

Permalink
Document get_db_results
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkb committed Dec 1, 2023
1 parent b5fb362 commit 324fe92
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/api/views/media_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ def _get_request_serializer(self, request):
return req_serializer

def get_db_results(self, results):
"""
Map ES hits to ORM model instances.
ORM instances have all necessary info needed for serializers whereas ES
hits only contain the subset of fields needed for indexing and search.
This function issues one query to the DB, using the ``identifier`` field
which is both unique and indexed, so it's quite performant.
:param results: the list of ES hits
:return: the corresponding list of ORM model instances
"""

identifiers = []
hits = []
for hit in results:
Expand Down

0 comments on commit 324fe92

Please sign in to comment.