Hello,

I'm new to lucene and I am having some trouble figuring out the right way
to use a SearcherTaxonomyManager for NRT faceted search. Assuming I set up
the STM with a reopen thread:

    // Index Writer
    Directory indexDir = FSDirectory.open(new File(indexDirectoryPath));
    IndexWriterConfig cfg = new IndexWriterConfig(VERSION, ANALYZER);
    TrackingIndexWriter trackingIndexWriter = new TrackingIndexWriter(new
IndexWriter(indexDir, cfg));

    // Taxonomy Writer
    Directory taxoDirectory = FSDirectory.open(new File(taxoDirectoryPath));
    DirectoryTaxonomyWriter taxoWriter = new
DirectoryTaxonomyWriter(taxoDirectory);

    // SearcherTaxonomyManager
    SearcherTaxonomyManager stm = new
SearcherTaxonomyManager(trackingIndexWriter.getIndexWriter(), true, new
SearcherFactory(), taxoWriter);

    // Reopen Thread
    Thread reopenThread = new
ControlledRealTimeReopenThread<SearcherTaxonomyManager.SearcherAndTaxonomy>(trackingIndexWriter,
stm, 5.0, 0.05);
    reopenThread.setName("Reopen Thread");
    reopenThread.setPriority(Math.min(Thread.currentThread().getPriority()
+ 2, Thread.MAX_PRIORITY));
    reopenThread.setDaemon(true);
    reopenThread.start();

and I always use the tracking index writer to index documents:

    trackingIndexWriter.updateDocument(...)

and I always use the STM to perform searches:

    SearcherTaxonomyManager.SearcherAndTaxonomy st = stm.acquire();
    try {
        DrillSideways drillSideways = new DrillSideways(st.searcher,
st.taxonomyReader);
        DrillSideways.DrillSidewaysResult dsr = drillSideways.search(...);
        ...
    } finally {
        stm.release(st);
    }

My understanding is that the index writer and the taxo writer will handle
flushing updates to disk periodically (whenever their buffers are full),
and the ReopenThread will handle flushing the deletes periodically (and
making sure I have a reader that sees the latest changes).

If that is true, and I call close() on the index writer and the taxonomy
writer during shutdown:

    reopenThread.interrupt();
    reopenThread.close();
    taxoWriter.close();
    trackingIndexWriter.getIndexWriter().close(true);

do I ever need to explicitly call commit() on the index writer or the taxo
writer?

Reply via email to