我使用下面的代码进行搜索,但某些方法显示错误;
FSDirectory.open(new File(indexDirectoryPath));
writer = new IndexWriter(indexDirectory,
new StandardAnalyzer(),true,
IndexWriter.MaxFieldLength.UNLIMITED);
在此代码中打开,MaxFieldLength 显示错误。我使用的是lucene 6.0.0。
open()方法显示错误
The method open(Path) in the type FSDirectory is not applicable for the arguments (File)
和MaxFieldLength显示:
MaxFieldLength cannot be resolved or is not a field
我使用了此处提供的代码:
http://www.tutorialspoint.com/lucene/lucene_first_application.htm
最佳答案
该代码可能是针对旧版本的 lucene 编写的。
较新的版本已从旧的 java io 切换到 java nio。
所以你会使用这样的东西:FSDirectory.open(FileSystems.getDefault().getPath("yourPath", "index")
在版本 6.0 中,IndexWriter 没有名为 MaxFieldLength
的成员,请参阅 Lucene IndexWriter API .
更多帮助可以在migration guide中找到
您可能也不想查找旧版本的迁移指南。
关于java - Lucene在java中找不到方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36542551/