Hi Emmanuel!
2. add an FullTextSession.optimize(Class) method, and the
application
is responsible for the method trigger. This is the easy solution but
put more work on the user. And I'm not happy to push a maintenance API
to the Session. Esp since this is more of a SessionFactory like API.
+1
3. optimize every N operations. It is trivial to add a counter per
DirectoryProvider and trigger the optimization. N should be customizable
+1
I've too written a lucene indexing server, and use those both approaches.
Optimization after - say 1000 operations and trigger an optimization at
3:00 o clock in the morning - works pretty well.
Another idea might be:
5. optimize after N time units (seconds/minutes/hours) idle time. So -
if set to say 3 hours - this might trigger an optimization in the
evening when nobody is bothered.
To gain even more performance with optimization and large indexes: Is it
possible with Hibernate Search to partition the index, so to have
multiple small indexes? You might know if there are deleted documents in
one of the index partition and then optimize only those partitions.
Ciao,
Mario