HCSVLAB-327: Tidied up the query so that the duplicate documents are avoided