Bug 509819 - NPE in SearchIndex.removeDocument

Change-Id: I183b9197ee32c093deb7400aac640ccb2ac59ae3
Signed-off-by: Sopot Cela <scela@redhat.com>
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
index 3ab7e7a..339d2f1 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/search/SearchIndex.java
@@ -329,13 +329,13 @@
 	 */
 	public synchronized boolean beginDeleteBatch() {
 		try {
-			if (ir != null) {
-				ir.close();
+			if (iw != null) {
+				iw.close();
 			}
 			indexedDocs = new HelpProperties(INDEXED_DOCS_FILE, indexDir);
 			indexedDocs.restore();
 			setInconsistent(true);
-			ir = DirectoryReader.open(luceneDirectory);
+			iw = new IndexWriter(luceneDirectory, new IndexWriterConfig(analyzerDescriptor.getAnalyzer()));
 			return true;
 		} catch (IOException e) {
 			HelpBasePlugin.logError("Exception occurred in search indexing at beginDeleteBatch.", e); //$NON-NLS-1$
@@ -422,10 +422,10 @@
 	 */
 	public synchronized boolean endDeleteBatch() {
 		try {
-			if (ir == null)
+			if (iw == null)
 				return false;
-			ir.close();
-			ir = null;
+			iw.close();
+			iw = null;
 			// save the update info:
 			// - all the docs
 			// - plugins (and their version) that were indexed