1. A method for retrieving an electronic document in response to receipt of an image patch, the method comprising: receiving the image patch; identifying a first two-dimensional structure in the image patch; identifying a second two-dimensional structure in the image patch; identifying a third two-dimensional structure in the image patch; generating a first text string that encodes the first two-dimensional structure into a first one-dimensional structure by specifying a location of the first two-dimensional structure, a first quantized angle measured between a line originating from the first two-dimensional structure and a path joining a center of the first two-dimensional structure to a center of the second two-dimensional structure and a second quantized angle defining a path joining a center of the second two-dimensional structure to a center of the third two-dimensional structure; searching, from a library, for a second one-dimensional structure that is similar to the first one-dimensional structure of the image patch; and retrieving the electronic document corresponding to the second one-dimensional structure similar to the first one-dimensional structure of the image patch from a document storage.