We're updating the issue view to help you get more done. 

Provide access to IndexWriter.optimize()

Description

The problem is not solved "automatically" yet. But here is the reason why.
First of all, the elements are properly deleted, and the index file reflect that as soon as IndexReader.close() is called (which is done by Hibernate Search). However, the files containing the document data are not cleaned.
Basically, to physically delete the elements, you need to optimize() your index, this operation typically takes more time and doing it for every single delete is not appropriate.

I see 4 solutions:
1. let the user access the Directory and call the indexWriter.optimize() method. It works today but it sucks.
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.
2bis. publish this API through JMX
3. optimize every N operations. It is trivial to add a counter per DirectoryProvider and trigger the optimization. N should be customizable
4. optimize every N seconds. either by setting a timer in an additional thread or wait for the next operation and compare the timestamp

2(bis or not) and 3 are my favorites. It's really 2 or 3 hours of work. If someone is interested, ping me.

Environment

None

Status

Assignee

Unassigned

Reporter

Emmanuel Bernard

Fix versions

Affects versions

3.0.0.beta3

Priority

Major