1. A method comprising, by one or more computing devices: receiving, from a client device associated with a first user of an online social network, an unstructured text query comprising one or more n-grams, the online social network being associated with a social graph comprising a plurality of nodes and a plurality of edges connecting the nodes; identifying one or more of the nodes based at least on a determined probability for each node that the node corresponds to at least one of the n-grams, each of the identified nodes matching at least a portion of one or more of the n-grams; identifying one or more of the edges, each of the identified edges being connected to at least one of the identified nodes, each of the identified edges matching at least a portion of one or more of the n-grams; generating one or more structured queries that each comprise the n-grams of the text query and references to one or more of the identified nodes and one or more of the identified edges; and sending, to the client device associated with the first user in response to receiving the text query, one or more of the structured queries for presentation to the first user.