1. A method of processing a query, the method comprising: generating, from a query string, an effective string set comprising a plurality of partial strings which have a variety of lengths; generating a plurality of subsets of the effective string set, each respective subset comprising one or more of the partial strings; determining a subset from the plurality of subsets as a candidate set based on access costs of the plurality of subsets for a database in which information about a plurality of documents is stored; and searching for a document comprising the query string from the information stored in the database using the candidate set.