Might not be the solution that you are looking for, but I find that complex queries are sometimes best represented as a function. Assuming that’s Postgres, here is an example of how I wrapped a search results function in Phoenix a while back.
It’s not updated for more recent versions, but same idea might be a good fit for the “don’t overthink it” approach. I think something similar would translate well with the schema/context approach.


















