java - Lucene在java中找不到方法

标签 java lucene

我使用下面的代码进行搜索,但某些方法显示错误;

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

在此代码中打开,MaxFieldLength 显示错误。我使用的是lucene 6.0.0。

open()方法显示错误

The method open(Path) in the type FSDirectory is not applicable for the arguments (File)

和MaxFieldLength显示:

MaxFieldLength cannot be resolved or is not a field

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

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

相关文章:

java - 通过 ObjectOutputStream 发送相同但已修改的对象

java - 在jsf 2.2中上传文件

search - Solr分布式搜索与联合搜索相同吗?

java - Hibernate Search/Lucene - 使用单个查询搜索不相关的实体并对其进行排名

lucene - ElasticSearch - 返回查询方面的完整值

lucene - 如何获得Solr/lucene中的总匹配数

java - 为多个字段构建 Lucene 查询

java - 整数数组如何成为引用类型?

java - 图书馆和图书类,构造函数

java - 传递 3 个 double 和一个字符串,但我的最后两个变量被类忽略