如何使用TermVector

如何使用TermVector

本文介绍了如何使用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的索引中包含Term Vector的方法?

Is there a way to include the Term Vector in my indexing in Lucene 4.0 with the new constructors?

谢谢

推荐答案

TextField是一个方便的用户没有术语向量的索引字段。如果您需要术语向量,只需使用。它需要更多代码行,因为您需要创建首先,将 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 11:10