brianchandotcom/liferay-portal — pull request #5877 by matethurzo (2012-06-29 15:48:45+00:00)
Title: LPS-25816 Restructuring Lucene index deletion

Hi Brian,

I still owe you this set of change. I'm not sure if you remember that when I've upgraded the Lucene to 3.5 I've identified some problems with the windows JVM and Lucene collaboration. (https://github.com/brianchandotcom/liferay-portal/pull/5223)

The solution back then was to run a System.gc() before we deleting the index, but as we had a discussion it's not really a good solution since the behavior of the GC is not deterministic.

This change supposed to fix that, now it does not rely on the System.gc() anymore.

I was hesitating that I should separate the index deletion behavior for windows like system and linux like system, but I have decided to do the same for every kind of platform, it feels more consistent this way. Basically the index deletion is now handled with the Lucene API itself, the Lucene will delete the documents in the index. The same happens when we read back the index from a dump, the Lucene will read it and insert it. According to the Lucene doc, the deleteAll method is the most efficient for deleting, and also for querying this way seems to be the best.

Please let me know if you have any concerns with this solution, in that case I'll re-do the change.

Thanks,

Máté