Crafting the Path: Robust Query Rewriting for Information Retrieval