Skip to content

Related query does not use filtered index #3348

Closed as not planned
Closed as not planned

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:

results = related_media(
uuid=identifier,
index=self.default_index,
filter_dead=True,
)

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").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions