Implement document exists functionality.