// Helper method to transform an IndexTank Document to a Lucene Document
  private static org.apache.lucene.document.Document asLuceneDocument(Document itd) {
    org.apache.lucene.document.Document doc = new org.apache.lucene.document.Document();
    for (String field : itd.getFieldNames()) {
      doc.add(new Field(field, itd.getField(field), Field.Store.NO, Field.Index.ANALYZED));
    }

    return doc;
  }
  /** @inheritDoc */
  public synchronized void add(final String docId, final Document itdoc) {
    if (null == docId) {
      logger.error("No documentId specified. Ignoring addition.");
      return;
    }

    org.apache.lucene.document.Document doc = asLuceneDocument(itdoc);
    org.apache.lucene.document.Field docidPayloadField =
        new org.apache.lucene.document.Field(
            LsiIndex.PAYLOAD_TERM_FIELD, docId, Field.Store.NO, Field.Index.ANALYZED);
    doc.add(docidPayloadField);

    doc.add(new Field("documentId", docId, Field.Store.NO, Field.Index.NOT_ANALYZED));
    try {
      if (logger.isDebugEnabled()) {
        logger.debug("Adding document with docId=" + docId + ". Doc is " + itdoc.getFieldNames());
      }
      writer.updateDocument(docIdTerm(docId), doc);
    } catch (IOException e) {
      logger.error(e);
    }
  }