ArrayList tokenizedList = new ArrayList();
ArrayList unTokenizedList = new ArrayList();
TextService textAction = (TextService) Constants.getBean("textService");//获取正文
Hashtable tokenizedTable = null;//需要切词建索引的数据
Hashtable unTokenizedTable = null;//不需要切词建索引的数据
for (int i = 0; i < values.length; i++) {
LobText text = textAction.getTextByLinkId(values[i]);//正文
tokenizedTable = new Hashtable();
tokenizedTable.put("content", textAction.getLobContent(text));
tokenizedTable.put("title", title));
tokenizedList.add(tokenizedTable);
unTokenizedTable = new Hashtable();
unTokenizedTable.put("reportTime", LuceneDateFieldFormat.foramtDateToString(reportTime));//上报时间
unTokenizedTable.put("createrDept", createrDept);//上报部门
unTokenizedList.add(unTokenizedTable);
}
for (int i = 0; i < tokenizedList.size(); i++) {
//先删除索引,再添加索引
sucessed_index = luceneAssistant.makeIndex(values[i], (Hashtable) tokenizedList.get(i), (Hashtable) unTokenizedList.get(i), false);
}
Lucene 应用实例(添加索引)
最新推荐文章于 2022-05-28 16:27:58 发布