I tried to create a simple Lucene program to create index, But I am having trouble why my syntax iswrong.
My code:
static final String INDEX_DIRECTORY = "/home/yuqing/Desktop/index";
Directory index = FSDirectory.open(new File(INDEX_DIRECTORY));
I get an error from IDE saying
open (java.nio.file.path) in FSDirectory cannot be applied to java.io.file
The
FSDirectory.open
call takes aPath
argument, not aFile
(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:
You should use .toPath() for the path to files.