gpt4 book ai didi

java - Java 中的 ElasticSearch 库无法找到 AggregationBuilders.sum 方法

转载 作者:行者123 更新时间:2023-12-02 09:27:10 24 4
gpt4 key购买 nike

我试图在java中使用ElasticSearch的AggregationBuilders api来查找总和聚合。但是在使用使用此(AggregationBuilders.sum())方法的服务时,它给出以下错误:

java.lang.NoSuchMethodError:org.elasticsearch.search.aggregations.;

这是我的 pom.xml 文件

    <dependencies>
<!-- Elasticsearch dependencies -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-high-level-client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch.plugin/transport-netty4-client -->
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>7.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>3.2.0.M1</version>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
<version>2.0.0.M2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.0.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>2.1.5.RELEASE</version>
</dependency>

</dependencies>```


到目前为止,我已尝试清理 .m2 并再次运行干净安装,但仍然出现此错误。任何帮助将不胜感激:

PS:更改 pom 后,我可以停止安装 elasticsearch 6.5,但 6.4.3 仍在安装。我只想要 7.2 版本。知道如何找到导致其他版本安装的依赖项

es模块新增Pom

        <!-- Elasticsearch dependencies -->
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-high-level-client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch.plugin/transport-netty4-client -->
<!--<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>transport-netty4-client</artifactId>
<version>7.2.0</version>
</dependency>-->

<!-- <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
<version>2.0.0.M2</version>
<scope>compile</scope>
</dependency>-->


</dependencies>

这是聚合器项目的 pom:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.dummy.proj</groupId>
<artifactId>dummy-proj</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>es</module>
<module>ms</module>
</modules>

<properties>
<!-- These Properties are common for all spring R&D for maven build-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<common.lang.version>2.4</common.lang.version>
<dummy.version>1.0-SNAPSHOT</dummy.version>
<lombok.version>1.16.18</lombok.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.10.0</version>
</dependency>
</dependencies>

<!--

<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</repository>
</repositories>
-->


<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

</project>```

最佳答案

Spring Data Elasticsearch 3.2 不适用于 Elasticsearch 7; 3.2.0.GA使用Elasticsearch 6.8。

对 Easticsearch 7 的支持和适配位于当前的主分支中,稍后将成为版本 4

关于java - Java 中的 ElasticSearch 库无法找到 AggregationBuilders.sum 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58266367/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com