如何在Lucene 4.0中控制索引字段 [英] How to control Indexing a field in lucene 4.0
问题描述
直到Lucene 3.9版,我们可以使用FIELD.INDEX.NO或FIELD.INDEX.ANALYZED等指定对字段进行索引还是不对索引进行索引.但是在Lucene 4.0中,没有可用的构造函数,我们可以在其中定义该字段.在此版本中,我们如何控制索引编制?
Until Lucene version 3.9 , we could specify to index or not to index a field by using FIELD.INDEX.NO or FIELD.INDEX.ANALYZED etc. But in lucene 4.0 there is no constructor available, in which we may define this . How do we control indexing in this version?
我的意思是,如果我希望将字段名称"存储在索引中但不希望对其进行索引,那么我该如何在lucene 4.0中做到这一点?
I mean if i want a field "name" to be stored in index but doesn't want to index it, then how can i do it in lucene 4.0?
推荐答案
采用Field.Index
自变量的构造函数是可用的,但在4.0中已弃用,因此不应使用.相反,您应该查看Field
的子类来控制字段的索引方式.
Constructors taking Field.Index
arguments are available, but are deprecated in 4.0, and should not be used. Instead, you should look to subclasses of Field
to control how a field is indexed.
-
StringField
是标准的未分析索引字段.被索引的字段是单个令牌.像标识符之类的适当的东西,您只需要搜索完全匹配即可.
StringField
is the standard un-analyzed indexed field. The field is indexed is a single token. It is appropriate things like identifiers, for which you only need to search for exact matches.
TextField
是用于文本内容的标准分析字段(当然也包括索引字段).这是全文搜索的合适选择.
TextField
is the standard analyzed (and, of course, indexed) field, for textual content. It is an appropriate choice for full-text searching.
StoredField
是一个根本没有索引的存储字段(因此是不可搜索的).
StoredField
is a stored field that is not indexed at all (and so, is not searchable).
除了StoredField
,每个变量都可以传递一个Field.Store
值作为构造函数参数,类似于Lucene 3.6.
Except StoredField
, each of these can be passed a Field.Store
value as a constructor argument, similar to Lucene 3.6.
有关此更改的更多信息,请参阅 Lucene迁移指南,尤其是标题为"从字段实例中分离IndexableFieldType "的部分
For more information on this change, take a look at the Lucene Migration Guide, particularly the sections titled: "Separate IndexableFieldType from Field instances"
这篇关于如何在Lucene 4.0中控制索引字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!