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
推荐答案
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Lucene 使用 FSDirectory
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- Struts2 URL 无法访问 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
