1. A method comprising: receiving a query comprising a term from a user; determining a user identifier of the user and a term identifier associated with the term; gathering post identifiers and user identifiers that are associated with the term identifier in a user-term index comprising time-ordered database shards of records, where the user-term index is organized by a plurality of user identifiers associated with a plurality of users of a social networking system and a plurality of term identifiers associated with a plurality of terms used by the plurality of users; retrieving posts from an index based upon the gathered post identifiers for presentation to the user; determining user identifiers of connections of the user; and selecting partitions that are associated with the user identifiers of the connections of the user from among a plurality of partitions of the user-term index, wherein gathering post identifiers comprises gathering post identifiers that are associated with the term identifier in the selected partitions of the user-term index.