deindex content when you delete it.
[mir.git] / source / mircoders / search / IndexUtil.java
index 3389ebd..a61f5c3 100755 (executable)
@@ -59,4 +59,25 @@ public class IndexUtil {
       }
     }
   }
+  public static void unindexID (String id,String index) throws IOException{
+    IndexReader indexReader = null;
+    try{
+      indexReader = IndexReader.open(index);
+      indexReader.delete(new Term("id",id));
+      indexReader.close();
+    }
+    catch(Exception e){
+      if (indexReader != null){
+       indexReader.close();
+      }
+    }
+    finally { 
+      if (indexReader != null){
+       FSDirectory theIndexDir=FSDirectory.getDirectory(index,false);
+       if (IndexReader.isLocked(theIndexDir)){
+         IndexReader.unlock(theIndexDir);
+       }
+      }
+    }
+  }
 }