How to use TermVector Lucene 4.0(如何使用 TermVector Lucene 4.0)
问题描述
在索引方法中,我使用以下行:
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 TermVector Lucene 4.0


基础教程推荐
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 降序排序:Java Map 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01