您的位置:首页 > 其它

CCNP之多组负载均衡[HSRP]配置实例

2009-10-31 14:55 417 查看
public void searchContent(String type,String keyword){    // 根据指定的检索内容类型type,以及检索关键字keyword进行检索操作
try {
IndexSearcher searcher = new IndexSearcher(this.indexPath);    // 根据指定路径,构造一个IndexSearcher检索器
Term term = new Term(type,keyword);    // 创建词条
Query query = new TermQuery(term);    //   创建查询
Date startTime = new Date();
TermDocs termDocs = searcher.getIndexReader().termDocs(term);    // 执行检索操作
while(termDocs.next()){    //   遍历输出根据指定词条检索的结果信息
System.out.println("搜索的该关键字【"+keyword+"】在文件\n"+searcher.getIndexReader().document(termDocs.doc()));
System.out.println("中,出现过 "+termDocs.freq()+" 次");
}
Date finishTime = new Date();
long timeOfSearch = finishTime.getTime() - startTime.getTime();    //   计算检索花费时间
System.out.println("本次搜索所用的时间为 "+timeOfSearch+" ms");
} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: