code: func (w *IndexWriter) UpdateDocument(term *Term, doc []IndexableField, analyzer analysis.Analyzer) error {
  	w.ensureOpen()
  	var success = false
  	defer func() {
  		if !success {
  			if w.infoStream.IsEnabled("IW") {
  				w.infoStream.Message("IW", "hit error updating document")
  			}
  		}
  	}()
  
  	ok, err := w.docWriter.updateDocument(doc, analyzer, term)
  	if err != nil {
  		return err
  	}
  	if ok {
  		_, err = w.docWriter.processEvents(w, true, false)
  		if err != nil {
  			return err
  		}
  	}
  	success = true
  	return nil
  }
docs: // L1545
  /*
  Updates a document by first deleting the document(s) containing term
  and then adding the new document. The delete and then add are atomic
  as seen by a reader on the same index (flush may happen only after
  the add).
  */