lucene 删除索引
2011-05-26 18:42
351 查看
public static void deleteDocument(HttpServletRequest request, String id){
String pa = request.getRealPath("").replace("fangdake", "");
String pathdir =pa+"fasdq"+File.separator+PrePath ;
Analyzer analyzer = new IKAnalyzer();
File path = new File(pathdir);
try {
Directory directory = FSDirectory.open(path);
IndexReader reader = IndexReader.open(directory,false);
// indexWriter.setUseCompoundFile(true);
reader.deleteDocuments(new Term("id",id));
// reader.deleteDocument(10);
reader.flush();
reader.close();
System.out.println("删除索引");
} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (LockObtainFailedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
String pa = request.getRealPath("").replace("fangdake", "");
String pathdir =pa+"fasdq"+File.separator+PrePath ;
Analyzer analyzer = new IKAnalyzer();
File path = new File(pathdir);
try {
Directory directory = FSDirectory.open(path);
IndexReader reader = IndexReader.open(directory,false);
// indexWriter.setUseCompoundFile(true);
reader.deleteDocuments(new Term("id",id));
// reader.deleteDocument(10);
reader.flush();
reader.close();
System.out.println("删除索引");
} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (LockObtainFailedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
相关文章推荐
- lucene3.0更新索引时原索引不删除的问题
- Lucene中索引的删除,更新与查找以及恢复(lucene3.5)
- Lucene中创建索引的效率和删除索引的实现
- Lucene3.5 之 索引删除和更新
- lucene(全文搜索)_删除索引
- Lucene中索引的删除,更新与查找以及恢复(lucene3.5)
- Lucene.Net 删除索引DeleteDocuments的注意事项
- 删除索引DeleteDocuments:Lucene.Net 删除索引DeleteDocuments的注意事项
- 第二章:lucene构建索引(新增、查询、更新、删除)
- Lucene5 学习笔记(2) —— 简单介绍 Lucene 搜索功能和索引的修改、删除
- Lucene深入学习(11)Lucene的索引删除
- Lucene之删除索引
- Lucene创建、查询、删除、更新 索引
- Lucene 4.4 依据Int类型字段删除索引
- lucene中的删除索引
- Lucene索引删除、更新、恢复和加权操作
- lucene 新增 更新 删除索引
- Lucene索引操作,删除,更新,优化
- lucene索引管理(索引创建于删除)
- Lucene 4.4 根据Int类型字段删除索引