The document proposes a privacy-preserving personalized web search framework called UPS. UPS can generalize user profiles for each query according to user-specified privacy requirements. It uses two metrics to evaluate privacy breach risk and query utility for hierarchical user profiles. The framework includes two algorithms for generalizing user profiles at runtime. It also provides an online mechanism for deciding whether to personalize queries to enhance search quality while avoiding unnecessary privacy exposures. Extensive experiments showed the proposed approach efficiently protects privacy during personalized web searches.