1. A computer implemented method comprising: partitioning a set of queries into a plurality of clusters; for each query in the set of queries computing a suggestion tree: wherein a root node of the suggestion tree represents said each query, wherein for each child node of said suggestion tree an arc between said each child node and a parent node of said each child node represents a query rewrite provider, wherein said each child node represents a rewrite suggestion generated based on applying the query rewrite provider of the arc from the respective parent node to the rewrite suggestion or query represented by the parent node, and wherein the suggestion tree belongs to the cluster of said each query; generating a partitioning function for partitioning said queries into said plurality of clusters by performing a set of steps that include: scoring each suggestion tree generated for each query of said set of queries, said scoring including associating one or more child nodes of said each suggestion tree with data reflecting a quality of the rewrite suggestion represented by one or more said child nodes; for each cluster of said plurality of clusters, generating an aggregate suggestion tree based on each of the scored suggestion trees in the cluster; for each query of said set of queries: making a comparison of the suggestion tree of said each query to one or more representative aggregate trees generated for the plurality of clusters, and establishing a recommended cluster based on the comparison; using a machine learning algorithm to generate a partitioning function based on: features of each query of the plurality of queries, and the recommended cluster established for each query of the plurality of queries; applying the partitioning function to repartition said set of queries between said clusters; repeating the set of steps until an end condition is reached.