code: protected synchronized IndexWriter getIndexWriter() throws IOException
     {
        if (indexReader != null)
        {
           indexReader.close();
           log.debug("closing IndexReader.");
           indexReader = null;
        }
        if (indexWriter == null)
        {
           IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_36, analyzer);
           config.setSimilarity(similarity);
           if (config.getMergePolicy() instanceof LogMergePolicy)
           {
              ((LogMergePolicy)config.getMergePolicy()).setUseCompoundFile(useCompoundFile);
           }
           else if (config.getMergePolicy() instanceof TieredMergePolicy)
           {
              ((TieredMergePolicy)config.getMergePolicy()).setUseCompoundFile(useCompoundFile);
           }
           else
           {
              log.error("Can't set \"UseCompoundFile\". Merge policy is not an instance of LogMergePolicy. ");
           }
           indexWriter = new IndexWriter(directory, config);
           setUseCompoundFile(useCompoundFile);
           indexWriter.setInfoStream(STREAM_LOGGER);
        }
        return indexWriter;
     }
docs: Returns an <code>IndexWriter</code> on this index.
  @return an <code>IndexWriter</code> on this index.
  @throws IOException if the writer cannot be obtained.