The nearest neighbour problem in information retrieval: an algorithm using upperbounds