1. A computer-implemented method comprising: under control of a computing device having one or more processors with executable instructions, segmenting text in an image of a document into elements, each element representing a character in the text; grouping similar elements into clusters and assigning each cluster an identifier; replacing each element in a cluster of similar elements with the identifier allocated to the cluster of similar elements; ordering the identifiers within the document according to an order of the characters in the text; creating an index of identifiers in the document; receiving a text query and converting the text query into an image; segmenting the image into elements and matching each element to at least one cluster using a cluster table, the cluster table comprising mappings between identifiers and element characteristics; replacing each element in the image with at least one identifier based on the matching to formulate a query defined in terms of identifiers; and searching an index of identifiers using the query defined in terms of identifiers.