public Lucene delete(String id) throws IOException {
// 做删除标志
synchronized (this) {
TermQuery query=new TermQuery(new Term("id",id));
long num = indexWriter.deleteDocuments(query);
System.out.println("delete:"+num); //控制台打印为1
//indexWriter.forceMergeDeletes(); //控制台打印为0,删除之前有11个document
System.out.println(indexWriter.numDocs());
indexWriter.close();
}
return this;
}
我是这样删除的,使用deleteDocument(term)删除也是一样的结果,不知道是哪里出问题了