为什么Lucene中Field.Text和Field.Text没有定义

原因是因为版本问题。

Field.Text这个函数是 Lucene 1.x中的,在lucene 2.x不能用这种静态方法创建Field了,得直接new Field。

Lucene 1.x中的,如下:

document.add(Field.Text("path",dataFiles[i].getCanonicalPath()));
document.add(Field.Text("contents",txtReader));

在lucene2.2.0中已经改变了,如下:
doc.add(new Field("path",dataFile.getCanonicalPath(),Field.Store.YES,Field.Index.UN_TOKENIZED));
doc.add(new Field("contents",txtReader));

Field需要新建一个实例,而不是静态调用了。

原文地址:https://www.cnblogs.com/tv151579/p/2519078.html