您的位置:首页 > 其它

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();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  lucene string path file