Description
Description
@stacimc and I were looking at index memory usage after the production ASGI changes (which included the related query improvements from #3151), and noticed a difference in memory usage of the filtered and unfiltered image indexes. The graphs showed the filtered index query cache memory increasing after the deployment and the unfiltered index query cache memory decreasing. This made us wonder if the changes to the related query unintentionally included a change to the index queried for the related changes. The PR does not change which index we use for the related query. But we did notice that we're using the unfiltered index for related, rather than the filtered index.
The index used for related media is passed to the related media function by the view. MediaViewSet::related
passes the default index set on the media view set implementation:
openverse/api/api/views/media_views.py
Lines 162 to 166 in 6f6aac3
For images and audio, this is both the image
and audio
index names, which are the aliases used for the unfiltered indices.
The related_media
function passes this directly to Search
, meaning it queries the unfiltered index. To make things a bit clearer, we should change the related_media
function to accept the media type as a parameter, and then always query the filtered index for the media type. Pass the media type to make it clear that the index is chosen by the related_media
function and is always the filtered index for the media type. Then use the filtered index when constructing Search
, for example, search = Search(index=f"{media_type}-filtered")
.
Metadata
Assignees
Labels
Type
Projects
Status
✅ Done