lucene4入门(3)琐记

时间:2023-03-09 17:09:02
lucene4入门(3)琐记

欢迎转载http://www.cnblogs.com/shizhongtao/p/3440486.html

《--这个是lucene4.6的api下载地址,格式是chm的。需要的人可以下载http://ishare.iask.sina.com.cn/f/64138671.html--》

Field.Store

  • Store.YES:表示把对应字段存储到索引文件中去,方便进行还原。例如对一篇文章,其内容没有必要进行存储,只要存储对应id,方便去对应地方找到这篇文章就可以了。
  • Store.NO:不存储到索引文件中去,他与Index没有关系,也就是说不被存储也可以被索引;此时内容无法还原(利用document.get)

Field.Index

在4.5.1的api已经不推荐使用了。其中这样说:"This is here only to ease transition from the pre-4.0 APIs."类FieldType中有相应的方法来替代这个属性的设置。

TextField

api中介绍"A field that is indexed and tokenized, without term vectors. For example this would be used on a 'body' field, that contains the bulk of a document's text."

  • TextField(String name, Reader reader):这个方法通过源码你可以看到,他是调用父类的构造方法,并加入一个FiledType实例,并将这一实例.setIndexed(true);.setTokenized(true);而Store用的是默认值,当Store如果为true就会报出异常。