Lucene使用FSDirectory [英] Lucene using FSDirectory
本文介绍了Lucene使用FSDirectory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一个简单的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
推荐答案
有关路径类的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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文