Factor core query out to fedora-infra/datanommer#40.