Finish the cluster query function.