How to control Indexing a field in lucene 4.0

橙三吉。 提交于 2019-12-17 06:17:11

问题


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?

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?


回答1:


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 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 is the standard analyzed (and, of course, indexed) field, for textual content. It is an appropriate choice for full-text searching.

  • StoredField is a stored field that is not indexed at all (and so, is not searchable).

Except StoredField, each of these can be passed a Field.Store value as a constructor argument, similar to Lucene 3.6.

For more information on this change, take a look at the Lucene Migration Guide, particularly the sections titled: "Separate IndexableFieldType from Field instances"



来源:https://stackoverflow.com/questions/18564029/how-to-control-indexing-a-field-in-lucene-4-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!