我编写了一个简单的 java 程序来创建一个 lucene 索引,但是我得到了一个语法错误.
I wrote a simple java program to create a lucene index, but I get an error with the syntax.
我的代码:
static final String INDEX_DIRECTORY = "/home/yuqing/Desktop/index";
Directory index = FSDirectory.open(new File(INDEX_DIRECTORY));
我收到以下错误,
open (java.nio.file.path) in FSDirectory cannot be applied to java.io.file
FSDirectory.open
调用采用 Path
参数,而不是 文件
(从 Lucene 5.0 版开始).您可以查看 Java 路径类教程 了解信息关于它是如何工作的.
The FSDirectory.open
call takes a Path
argument, not a File
(as of Lucene version 5.0). You can check out the Java tutorial on the Path Class for information on how it works.
因此,您的代码应如下所示:
So, your code should look like:
static final String INDEX_DIRECTORY = "/home/yuqing/Desktop/index";
Directory index = FSDirectory.open(Paths.get(INDEX_DIRECTORY));
这篇关于Lucene 使用 FSDirectory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!