New readDocumentByQuery function