1. A method comprising: by a computer system, receiving a search term from a user of an online social-networking system; by the computer system, determining a search constraint for the search term based on social-networking information associated with the user; by the computer system, generating a search query comprising a first logical expression, the first logical expression comprising a first logical operator and at least two first operands, one of the first operands being the search term and another one of the first operands being the search constraint and an associated weight, the associated weight corresponding to a percentage, wherein the associated weight provides a limit on a number of search results for the search query that must match the search constraint, and wherein the search query permits at least a portion of the search results for the search query to match only the search term; and by the computer system, providing the search query for a search against a store of data.