Field沒了Keyword、UnIndexed、UnStored、Text這幾個靜態(tài)成員,只能用
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的有兩個參數(shù)的變成了depresed 了。現(xiàn)在要用只有一個參數(shù)的。
BooleanQuery的add方法也變了。原來是用兩個boolean值組合的,現(xiàn)在 使用BooleanClause.Occur的幾個靜態(tài)成員了。
暫時就發(fā)現(xiàn)這點差異。[引自:http://syre.blogbus.com/logs/4736803.html]
(二)Field類一共有5種構造函數(shù):
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中的數(shù)據(jù)是否在將來檢索時需要被用戶檢索到,一個“不索引”的Field通常僅是提供輔助信息儲存的功能。
Field.TermVector 表示“是否切詞”,即在這個Field中的數(shù)據(jù)是否需要被切詞。
通常,參數(shù)用Reader,表示在文本流數(shù)據(jù)源中獲取數(shù)據(jù),數(shù)據(jù)量一般會比較大。像鏈接地址URL、文件系統(tǒng)路徑信息、時間日期、人名、居民身份證、電話號碼等等通常將被索引并且完整的存儲在索引中,但一般不需要切分詞,通常用上面的第四個構造函數(shù),第三四個參數(shù)分別為Field.Store.YES, Field.Index.YES。而長文本通常可用第3個構造函數(shù)。引用[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的值分詞后建立索引。如果參數(shù)為String值將被保存,為Reader值不被保存
2. 2.0版本
用幾個內部類的組合來區(qū)分Field的具體類型。
COMPRESS:壓縮保存。用于長文本或二進制數(shù)據(jù)
YES:保存
NO:不保存
NO:不建索引
TOKENIZED:分詞,建索引
UN_TOKENIZED:不分詞,建索引
NO_NORMS:不分詞,建索引。但是Field的值不像通常那樣被保存,而是只取一個byte,這樣節(jié)約存儲空間
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 閱讀(1016)
評論(0) 編輯 收藏 所屬分類:
每日進階