Can a search profile be applied even with no `query` parameter? If not, I'd prefer to see no error get raised in this situation, but rather just silently ignore the search profile entirely if it can't be reasonably applied. (The public documentation for search profiles can make this clear.) If so, then the below logic needs to be refactored to handle the possibility of no query.