Lucene Field.Stror Field.Index

Field对象

从Lucene的源代码中,可以看出Field 典型构造函数如下:

Field(String name, String value, Field.Store store, Field.Index index)

其中:

Field.Index有四种属性,分别是:

Field.Index.TOKENIZED:分词索引

Field.Index.UN_TOKENIZED不分词进行索引,如作者名,日期等,不再需要分词。

Field.Index.NO:不进行索引,存放不能被搜索的内容如文档的一些附加属性如文档类型, URL等。

Field.Index.NO_NORMS:不分词,建索引.但是Field的值不像通常那样被保存,而是只取一个byte,这样节约存储空间。

Field.Store也有三个属性,分别是:

Field.Store.YES:索引文件本来只存储索引数据, 此设计将原文内容直接也存储在索引文件中,如文档的标题。

Field.Store.NO:原文不存储在索引文件中,搜索结果命中后,再根据其他附加属性如文件的Path,数据库的主键等,重新连接打开原文,适合原文内容较大的情况。

          Field.Store.COMPRESS 压缩存储。

 

Field Summary static 
           Index the tokens produced by running the field's value through an Analyzer. static 
           Expert: Index the tokens produced by running the field's value through an Analyzer, and also separately disable the storing of norms. static 
           Do not index the field value. static 
          Deprecated. This has been renamed to static 
           Index the field's value without using an Analyzer, so it can be searched. static 
           Expert: Index the field's value without an Analyzer, and also disable the storing of norms. static 
          Deprecated. this has been renamed to static 
          Deprecated. This has been renamed to