code: private void flushInternal()
      {
          try
          {
              if (w != null && readyForCommit)
              {
                  // w.optimize();
                  w.commit();
                  copy(index, FSDirectory.open(getIndexDirectory().toPath()));
                  readyForCommit = false;
                  reader = null;
                  isInitialized = false;
              }
          }
  
          catch (Exception e)
          {
              log.error("Error while Flushing Lucene Indexes, Caused by: ", e);
              throw new LuceneIndexingException("Error while Flushing Lucene Indexes", e);
          }
      }
docs: Flush internal.