【问题标题】:Error by importing Lucene LongField in eclipse在 Eclipse 中导入 Lucene LongField 时出错
【发布时间】:2016-10-26 13:03:18
【问题描述】:

我在 Eclipse 上使用 lucene 6.2.1,但在导入 LongFeild 时出错。 这是我导入的部分代码:

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.LongField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.Date;

唯一给我错误的行是

import org.apache.lucene.document.LongField;

我将 lucene-core-6.2.1.jar"、lucene-queryparser-6.2.1.jar" 和 lucene analyzers-common-6.2.1.jar" 添加到我的项目中。 有什么问题?

【问题讨论】:

    标签: java eclipse lucene


    【解决方案1】:

    在 Lucene 6.2.1 中,有一个 LegacyLongField,它被标记为已弃用,建议改用 LongPoint。

    LegacyLongField

    http://lucene.apache.org/core/6_2_1/core/org/apache/lucene/document/LegacyLongField.html

    长点

    http://lucene.apache.org/core/6_2_1/core/org/apache/lucene/document/LongPoint.html

    完整的 API 列表

    http://lucene.apache.org/core/6_2_1/core/index.html

    【讨论】:

    • 它和 LongField 完全一样吗?
    • LegacyLongField 的工作方式与 LongField 相同。它只是重命名,重新包装。 issues.apache.org/jira/browse/LUCENE-6917。 LongPoint 的实现非常不同。它可能需要您升级索引。
    猜你喜欢
    • 1970-01-01
    • 2013-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 2015-06-18
    • 2015-08-17
    相关资源
    最近更新 更多