code: public void upsert(Term term, Document document) {
          Log.debug("Updating document %s with term %s", document, term);
          try {
              indexWriter.updateDocument(term, document);
          } catch (IOException e) {
              Log.error(e, "Error while updating document %s with term %s", document, term);
              throw new RuntimeException(e);
          }
      }
docs: Updates the specified {@link Document} by first deleting the documents containing {@code 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).
  
  @param term     The {@link Term} to identify the document(s) to be deleted.
  @param document The {@link Document} to be added.