Adding k-nearest query