def doc(*arg)
      @dir.synchronize do
        id = arg[0]
        if id.kind_of?(String) or id.kind_of?(Symbol)
          ensure_reader_open()
          term_doc_enum = @reader.term_docs_for(@id_field, id.to_s)
          return term_doc_enum.next? ? @reader[term_doc_enum.doc] : nil
        else
          ensure_reader_open(false)
          return @reader[*arg]
        end
      end
    end
def doc(*arg)
      @dir.synchronize do
        id = arg[0]
        if id.kind_of?(String) or id.kind_of?(Symbol)
          ensure_reader_open()
          term_doc_enum = @reader.term_docs_for(@id_field, id.to_s)
          return term_doc_enum.next? ? @reader[term_doc_enum.doc] : nil
        else
          ensure_reader_open(false)
          return @reader[*arg]
        end
      end
    end
Retrieves a document/documents from the index. The method for retrieval
 depends on the type of the argument passed.

 If +arg+ is an Integer then return the document based on the internal
 document number.

 If +arg+ is a Range, then return the documents within the range based on
 internal document number.

 If +arg+ is a String then search for the first document with +arg+ in
 the +id+ field. The +id+ field is either :id or whatever you set
 +:id_field+ parameter to when you create the Index object.