随笔 - 44  文章 - 78  trackbacks - 0
<2007年12月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

 Happy 牛 Year
一、一周至少写一篇博文;
二、每天至少学习半个小时。
三、奔向小牛!

常用链接

留言簿(6)

我参与的团队

随笔分类

随笔档案

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

(一)最近用Lucene开发全文检索。《Lucene in Action》这本书用的是Lucene 1.4。我自己下的是最新的2.1。然后就发现了很多不同的地方。

Field没了Keyword、UnIndexed、UnStored、Text这几个静态成员,只能用
Field(String, String, Store, Index)。
Keyword对应Field.Store.YES, Field.Index.UN_TOKENIZED,
UnIndexed 对应Field.Store.YES, Field.Index.NO,
UnStored对应Field.Store.NO, Field.Index.TOKENIZED,
Text对应Field.Store.YES, Field.Index.TOKENIZED。

FSDirectory.getDirectory的有两个参数的变成了depresed 了。现在要用只有一个参数的。

BooleanQuery的add方法也变了。原来是用两个boolean值组合的,现在 使用BooleanClause.Occur的几个静态成员了。

暂时就发现这点差异。[引自:http://syre.blogbus.com/logs/4736803.html]

(二)Field类一共有5种构造函数:

Field(String name, byte[] value, Field.Store store)
           Create a stored field with binary value.
Field(String name, Reader reader)
           Create a tokenized and indexed field that is not stored.
Field(String name, Reader reader, Field.TermVector termVector)
           Create a tokenized and indexed field that is not stored, optionally with storing term vectors.
Field(String name, String value, Field.Store store, Field.Index index)
           Create a field by specifying its name, value and how it will be saved in the index.
Field(String name, String value, Field.Store store, Field.Index index, Field.TermVector termVector)
           Create a field by specifying its name, value and how it will be saved in the index.

其中:

Field.Store 表示“是否存储”,即该Field内的信息是否要被原封不动的保存在索引中。

Field.Index 表示“是否索引”,即在这个Field中的数据是否在将来检索时需要被用户检索到,一个“不索引”的Field通常仅是提供辅助信息储存的功能。

Field.TermVector 表示“是否切词”,即在这个Field中的数据是否需要被切词。

通常,参数用Reader,表示在文本流数据源中获取数据,数据量一般会比较大。像链接地址URL、文件系统路径信息、时间日期、人名、居民身份证、电话号码等等通常将被索引并且完整的存储在索引中,但一般不需要切分词,通常用上面的第四个构造函数,第三四个参数分别为Field.Store.YES, Field.Index.YES。而长文本通常可用第3个构造函数。引用[http://blog.csdn.net/colasnail/archive/2007/03/21/1536417.aspx]

(三)1.       2.0以前的版本

UnIndexed: Field的值将被保存到索引文件,不为Field的值建立索引,因此不能通过该Field搜索文档。 UnStored: Field的值不被保存到索引文件,将Field的值分词后建立索引

tags:Lucene Lucene.net Field Field.store Field.UnStored Field.Keyword Field.Text

  • Text: Field的值分词后建立索引。如果参数为String值将被保存,为Reader值不被保存
2.       2.0版本
    用几个内部类的组合来区分Field的具体类型。
  • Store
        COMPRESS:压缩保存。用于长文本或二进制数据
        YES:保存
        NO:不保存
  • Index
        NO:不建索引
        TOKENIZED:分词,建索引
        UN_TOKENIZED:不分词,建索引
        NO_NORMS:不分词,建索引。但是Field的值不像通常那样被保存,而是只取一个byte,这样节约存储空间
  • TermVector
        NO不保存term vectors
        YES保存term vectors。
        WITH_POSITIONS保存term vectors。(保存值和token位置信息)
        WITH_OFFSETS保存term vectors。(保存值和Token的offset)WITH_POSITIONS_OFFSETS:保存term vectors。(保存值和token位置信息和Token的offset)


comefrom:http://hi.baidu.com/gw_noah/blog/item/0646fbc4c3418daa8226ac0c.html
posted on 2007-12-03 15:30 Tiger1102 阅读(996) 评论(0)  编辑  收藏 所属分类: 每日进阶

只有注册用户登录后才能发表评论。


网站导航: