問題描述
在索引方法中,我使用以下行:
In the indexing method I use the following line:
Field contentsField = new Field("contents", new FileReader(f), Field.TermVector.YES);
但是,在 Lucene 4.0 中,此構造函數已被棄用,應使用 new TextField
代替 new Field
.
However, in Lucene 4.0 this constructor is deprecated and new TextField
should be used instead of new Field
.
但 TextField
的問題在于它的構造函數中不接受 TermVector
.
But the problem with TextField
is that it don't accept TermVector
in its constructors.
有沒有辦法使用新的構造函數在我的 Lucene 4.0 索引中包含術語向量?
Is there a way to include the Term Vector in my indexing in Lucene 4.0 with the new constructors?
謝謝
推薦答案
TextField 是一個方便的類,適用于需要沒有術語向量的索引字段的用戶.如果您需要術語向量,只需使用 字段.由于您需要創建 FieldType 首先,將 storeTermVectors
和 tokenizer
設置為 true,然后在 中使用這個
構造函數.FieldType
實例>字段
TextField is a convenience class for users who need indexed fields without term vectors. If you need terms vectors, just use a Field. It takes a few more lines of code since you need to create an instance of FieldType first, set storeTermVectors
and tokenizer
to true and then use this FieldType
instance in Field
constructor.
這篇關于如何使用 TermVector Lucene 4.0的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!