code: protected synchronized void commit(final boolean optimize) throws IOException
     {
        if (indexReader != null)
        {
           log.debug("committing IndexReader.");
           indexReader.flush();
        }
        if (indexWriter != null)
        {
           log.debug("committing IndexWriter.");
           indexWriter.commit();
        }
        // optimize if requested
        if (optimize)
        {
           IndexWriter writer = getIndexWriter();
           writer.forceMerge(1, true);
           writer.close();
           indexWriter = null;
        }
     }
docs: Commits all pending changes to the underlying <code>Directory</code>.
  
  @param optimize if <code>true</code> the index is optimized after the
  commit.
  @throws IOException if an error occurs while commiting changes.