【问题标题】:Configure build path problem in eclipse - javaeclipse中配置构建路径问题-java
【发布时间】:2020-10-05 10:53:12
【问题描述】:

我将弹性搜索从 5.5 升级到 7.7,一切正常。 但是当我尝试获取 Total hits 时,出现以下错误

searchResponse.getHits().getTotalHits()

org.apache.lucene.search.TotalHits 类型无法解析。它是从所需的 .class 文件中间接引用的

我们没有使用 lucene 库,但它仍然说它指的是 lucene, 感谢您提供任何帮助来解决此问题。

Maven pom.xml:

我只有这两个罐子,

<dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>7.7.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.11.1</version>
        </dependency>

谢谢,
哈利

【问题讨论】:

  • 能否请您使用您的 maven/gradle 配置更新问题,看起来缺少 lucene 库。
  • @OpsterESNinja-Kamal 更新了 pom.xml,但以前可能是 lucene 上的 jars 可能已经存在,我现在删除了
  • 如果您没有删除 lucene jar,您可以使用以下答案,也可以使用 link 以便 maven 重新下载所需的依赖项。

标签: java elasticsearch elasticsearch-5 buildpath elasticsearch-7


【解决方案1】:

this link 所述,您可能需要添加以下依赖项:

<repository>
    <id>elastic-lucene-snapshots</id>
    <name>Elastic Lucene Snapshots</name>
    <url>https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/00142c9</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>false</enabled></snapshots>
</repository>

根据this link,您可能还需要添加 Log4j 依赖项:

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.11.1</version>
</dependency>

这应该可以解决问题。

或者,您也可以添加下面的 lucene 依赖项,如果您只是执行http://&lt;hostname&gt;:9200,您可以看到确切的版本,但是我建议使用上述方法并按照他们的文档进行操作。

<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-core</artifactId>
    <version>8.5.1</version>
</dependency>

希望有帮助!

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2011-09-19
  • 2021-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-20
  • 2020-06-15
相关资源
最近更新 更多