reversing search code for documents