Related query does not use filtered index #3348
Labels
🕹 aspect: interface
Concerns end-users' experience with the software
🛠 goal: fix
Bug fix
🟨 priority: medium
Not blocking but should be addressed soon
🧱 stack: api
Related to the Django API
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
andaudio
index names, which are the aliases used for the unfiltered indices.The
related_media
function passes this directly toSearch
, meaning it queries the unfiltered index. To make things a bit clearer, we should change therelated_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 therelated_media
function and is always the filtered index for the media type. Then use the filtered index when constructingSearch
, for example,search = Search(index=f"{media_type}-filtered")
.The text was updated successfully, but these errors were encountered: