1、索引的创建步骤
1)创建Directory
2)创建IndexWriter
3)创建文档并且添加索引
4)查询索引的基本信息
5)删除和更新索引
directory=FSDirectory.open(new File("E:/lucene/index02"));
writer=new IndexWriter(directory,
new IndexWriterConfig(Version.LUCENE_35, new StandardAnalyzer(Version.LUCENE_35)));
Document doc=null;
for(int i=0;i
doc.add(new Field("id",ids[i],Field.Store.YES,Field.Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field("email",emails[i],Field.Store.YES,Field.Index.NOT_ANALYZED));
doc.add(new Field("content",contents[i],Field.Store.NO,Field.Index.ANALYZED));
doc.add(new Field("name",names[i],Field.Store.YES,Field.Index.NOT_ANALYZED_NO_NORMS));
String et=emails[i].substring(emails[i].lastIndexOf("@")+1);
System.out.println(et);
/* if(scores.containsKey(et)){
doc.setBoost(scores.get(et));
}else{
doc.setBoost(0.5f);
}*/
writer.addDocument(doc);
}