隨筆 - 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 閱讀(1019) 評論(0)  編輯  收藏 所屬分類: 每日進階
          主站蜘蛛池模板: 商城县| 高雄市| 株洲市| 白朗县| 朝阳市| 永新县| 甘南县| 大洼县| 阳原县| 麻阳| 澄迈县| 延庆县| 晴隆县| 赣榆县| 雅江县| 荆州市| 五台县| 自贡市| 黑山县| 上思县| 凉山| 东山县| 富顺县| 广南县| 枣强县| 资讯 | 思茅市| 东山县| 阳谷县| 昌宁县| 云南省| 西昌市| 凤凰县| 乃东县| 武冈市| 东乡县| 右玉县| 察哈| 湖北省| 瑞金市| 抚宁县|