lucene 3.1 和 lucene 2.4 创建IndexWriter

lucene 2.4 :

Directory dir = null;
IndexWriter ramIndexWriter = new IndexWriter(dir, analyzer, true, MaxFieldLength.LIMITED);

lucene 3.1 : 
//3.1版本将indexWriter的要设置的信息封装在IndexWriterConfig,
// 但是 MaxFieldLength.LIMITED 没有封装在IndexWriterConfig,
// 应该在new IndexWriterConfig 时候将 分词器的子类传给它,
// 即 
Directory dir = null;
IndexWriterConfig fsConfig = new IndexWriterConfig(Version.LUCENE_31, new LimitTokenCountAnalyzer(analyzer, 10000));
config .setOpenMode(OpenMode.CREATE);
ndexWriter fsIndexWriter = new IndexWriter(dir, config);

现在两个IndexWriter 一样了! ⊙﹏⊙b汗!

 

 

你可能感兴趣的:(Lucene)