This question already has answers here:
Lucene using FSDirectory
                                
                                    (2个答案)
                                
                        
                4年前关闭。
            
        

我正在使用以下代码进行搜索,但是某些方法显示错误;

FSDirectory.open(new File(indexDirectoryPath));
  writer = new IndexWriter(indexDirectory,
     new StandardAnalyzer(),true,
     IndexWriter.MaxFieldLength.UNLIMITED);


在此代码中打开,MaxFieldLength显示错误。我正在使用Lucene 6.0.0。

open()方法显示错误


  FSDirectory类型的open(Path)方法不适用于
  参数(文件)


MaxFieldLength显示:


  MaxFieldLength无法解析或不是字段


我使用了此处提供的代码:

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 - 在Java方法中找不到Lucene ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36542551/

10-11 00:41
查看更多