public void method(){
int countNum = LuceneService.getMyLuceneInformationsCount(null);
// int count = 100;
int groupNum = 1000;//一组1000条
int group = 0;
if(countNum%groupNum == 0){
group = countNum/groupNum;
}else{
group = countNum/groupNum+1;
}
for(int a = 1;a<=group;a++){
System.out.println(a+"-----------"+group);
createIndex((a-1)*groupNum,groupNum,conn);
}
}
//分组创建索引
private void createIndex(int start,int limit,Connection conn){
<span style="white-space:pre"> </span>List<Information> infor = getInforList(start,limit,conn);
LuceneInformation.creteIndex(infor,INDEXPATH_Information);
}
//新闻查询
public static List<Information> getInforList(int start,int limit,Connection conn){
List<Information> list = new ArrayList<Information>();
Statement st = null;
ResultSet rs = null;
try {
st = conn.createStatement();
String sql = "select id,blRecommend,dtCreate,lngReadNum,strOrganName,version" +
",strPID,strInfoID,strInfoTitle,strInfoContent,strCreate,blDeleteState,blPass from information limit "+start+","+limit+"";
rs = st.executeQuery(sql);
while (rs.next()) {
Information info = new Information();
info.setId(rs.getLong("id"));
info.setStrRecomState(rs.getString("blRecommend"));
info.setDtCreate(rs.getTimestamp("dtCreate"));
info.setLngReadNum(rs.getLong("lngReadNum"));
info.setStrOrgan(rs.getString("strOrganName"));
info.setVersion(rs.getInt("version"));
info.setStrPID(rs.getLong("strPID"));
info.setStrInfoID(rs.getString("strInfoID"));
info.setStrInfoTitle(rs.getString("strInfoTitle"));
info.setStrInfoContent(rs.getString("strInfoContent"));
info.setFirst_name(rs.getString("strCreate"));
info.setBlDeleteState(rs.getBoolean("blDeleteState"));
info.setBlPass(rs.getBoolean("blPass"));
list.add(info);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(st != null){
try {
st.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(rs != null){
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return list;
}
//新闻总数 public void method(){ int countNum = LuceneService.getMyLuceneInformationsCount(null);// int count = 100; int groupNum = 1000;//一组1000条 int group = 0; if(countNum%groupNum =