Hi,
when using the new MassIndexer there are some methods to setup this behaviour:
Code:
MassIndexer m = fulltextSession.createIndexer()
.optimizeAfterPurge(false)
.optimizeOnFinish(false);
the "purge" phase is at the beginning, right after the deletion of all older documents; the finish phase is after all new
documents have been added.
The default is
true for both, but optimization is always disabled during intermediate steps for top performance (ignoring
automatic optimization settings).
In current stable versions (3.1.x) the default is to
not optimize automatically; optimization is enabled if
optimizer.operation_limit.max and/or
optimizerStrategy are set in configuration.
So if you want to disable automatic optimization *globally* make sure you don't set this values.
As a temporary hack, and not completely correct, you could cast the SearchFactory to SearchFactoryImpl,
doing so you will be able to expose
Code:
public addOptimizerStrategy(DirectoryProvider<?> provider, OptimizerStrategy optimizerStrategy)
and change the optimizerStrategy for a specific Directory to
NoOpOptimizerStrategy.
I was mentioning this as not completely correct as there is no correct synchronization in this use case (the class is sealed at framework's startup): there is no guarantee another thread will "see" the change, but you'll probably use the indexing from the same thread so this should work fine for you.
A more interesting alternative is to implement your own
OptimizerStrategy and write the code you like most,
whet I'd recommend however is to try the new MassIndexer.