How to create a relationship which filters by comparing the value of a nested resource of the target resource against the value of the source resource?

Good point with the composite index! Thanks for the tip.