Refactor context search query composition