code: public void optimize() throws CorruptIndexException, IOException
     {
        for (PersistentIndex index : indexes)
        {
           IndexWriter writer = index.getIndexWriter();
           writer.forceMerge(1, true);
        }
     }
docs: Index optimization using {@link IndexWriter#optimize()} method.