An optimization framework for query recommendation