implement the document queryy