A theory of indexing