日期:2014-05-20  浏览次数:20559 次

关于Lucene 中Field 的疑惑,懂Lucene者请进
刚开始学习Lucene 
   
  按照Lucene in Action 中的例子在eclipse 中运行,结果发现一点问题,由于对Lucene API还不太了解
   
  请高手帮忙解释一下;


问题是这样的

  doc.add(Field.Text("content",new FileReader(f)));
doc.add(Field.Keyword("filename",f.getCanonicalPath()));


  eclipse 提示 Field没有域或方法 Text 和 Keyword
   
  自己在API中也没有找到 Text 和 Keyword,这到底是什么原因呢?

------解决方案--------------------
注意版本问题,lucene in action 是对应1.4的版本,而现在的版本已经为2.4往上了
如果使用高版本的话,对于Field的初始化已经发生改变,如下:
new Field(String name,TokenStream)
new Field(String name,String value,Store,Index)
原有的Text,KeyWord已经不存在了,看看版本吧