版本变化:
IndexWriterConfig 类的构造方法;
Directory类的生成方法 FSDirectory.open(),(Path,File);
Field类中的存储问题,Intpoint取代IntField;
BooleanQuery() 的构造方法改变;
PointValues 取代了NumericField,.legacyXXField废弃;
WhitespaceAnalyzer类的废弃;
现在,Luene已经是6.6版本了,与之前的2.9,3.5,4.5,5等各个版本,已经很有些不同了。学习4.0之前的教程,我可是吃过不少亏的。
具体变化:
(1)IndexWriterConfig 类的构造方法:
这个类主要是充当创造/在索引过程中更新指标的对象。
原来Lucene4.0之前
writer  new IndexWriterindexDirectory,              new StandardAnalyzerVersion.LUCENE_36,true,
                    IndexWriter.MaxFieldLength.UNLIMITED
现在Lucene6
Analyzer new StandardAnalyzer        IndexWriterConfig iwc  new IndexWriterConfiganalyzer
        IndexWriter writer  new IndexWriterdir, iwc
(2)Directory类的生成方法 FSDirectory.open(),(Path,File);
这个类主要便是打开词盘中的文件,
原来Lucene4.0之前
Directory directory  FSDirectory.opennew File“C:”现在Lucene6
Directory directory  FSDirectory.openPath.get“C:”(3)Field类中的存储问题,Intpoint取代IntField;
原来的IntField类主要是实现整形的域内操作,而现在它主要改为Intpoint了,
原来Lucene用
 org.apache.lucene.document.IntField            document.addnew IntField, idi, Field.Store.YES
现在Lucene6用,需要配合StoredField来存储,需要NumericDocValuesField和StoredField来排序
 org.apache.lucene.document.IntPoint             doc.addnew NumericDocValuesField, idi//和下边排序 
            doc.addnew IntPoint, idi 
            doc.addnew StoredField, idi  //存储
(4)BooleanQuery() 的构造方法改变;
BooleanQuery()的作用范围是 private 的,只能在类的内部调用,最大的改变是多出了静态内部类 Builder ,加强了类自身的稳定性与安全性。
原来Lucene用
BooleanQuery query  new BooleanQuery        Query subQuery  querys 
             query.addsubQuery,Occur.SHOULD
             query
现在Lucene6用
 Query subQuery  querys         new BooleanQuery.Builder.addsubQuery,Occur.SHOULD.build
             query
(5)PointValues 取代了NumericField,.legacyXXField废弃
PointValues 更快,更小,更便于资源的利用,都被取代了legacy**,
原来Lucene
document.addnew IntField,             writer.addDocumentdocument
Query query  new NumericRangeQuery, , ,false,false
TopDocs docs  searcher.searchquery, .
现在Lucene6
document.addnew IntPoint,        writer.addDocumentdocument
Query query  IntPoint.newRangeQuery, , 
TopDocs docs  searcher.searchquery, .
(6)WhitespaceAnalyzer类的废弃;
参考:lucene6.6学习心得 http://www.voidcn.com/article/p-niqkzzcc-bmq.html


		
		
		

还没有评论,来说两句吧...