# Method getTotalHits() duplicated and not found at the same time?

**URL:** https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251
**Category:** Elasticsearch
**Created:** [January 30, 2020, 5:30pm UTC](https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251 "2020-01-30T17:30:44Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![franzisk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/franzisk/32/61527_2.png) [@franzisk](https://discuss.elastic.co/u/franzisk)
#### Post date: [January 30, 2020, 5:30pm UTC](https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251/1 "2020-01-30T17:30:44Z")

</div>

Hi,

I am using spring-boot-starter-elasticsearch and when I do query via repository I get this error saying the method getTotalHits() doesn't exist, at the same time shows on Eclipse console that there are 2 classes on the ClassPath with this method:

> ```
> > <properties>
> > <java.version>1.8</java.version>
> > <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> > <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
> > <elasticsearch.version>7.5.2</elasticsearch.version>
> > </properties>
> 
> ```

```
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.data.elasticsearch.core.ElasticsearchTemplate.doCount(ElasticsearchTemplate.java:512)

The following method did not exist:

    org.elasticsearch.search.SearchHits.getTotalHits()J

The method's class, org.elasticsearch.search.SearchHits, is available from the following locations:

    jar:file:/C:/Users/francisco.souza/.m2/repository/org/elasticsearch/elasticsearch/7.5.2/elasticsearch-7.5.2.jar!/org/elasticsearch/search/SearchHits.class

It was loaded from the following location:

    file:/C:/Users/francisco.souza/.m2/repository/org/elasticsearch/elasticsearch/7.5.2/elasticsearch-7.5.2.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of org.elasticsearch.search.SearchHits

```

Repository:  
public interface EventoRepository extends ElasticsearchRepository\<Evento, String\>{

```
	Optional<List<Evento>> findByDataLessThan(String data);
}

```

Did anyone faced something like this?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [January 31, 2020, 10:31am UTC](https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251/2 "2020-01-31T10:31:27Z")

</div>

When using springboot with  
elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your `pom.xml`:

```auto
<properties>
  <elasticsearch.version>7.5.2<elasticsearch.version>
</properties>

```

See documentation here: [https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions](https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html#howto-customize-dependency-versions)

---

<div class="post-metadata">

### Author: ![franzisk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/franzisk/32/61527_2.png) [@franzisk](https://discuss.elastic.co/u/franzisk)
#### Post date: [January 31, 2020, 2:15pm UTC](https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251/3 "2020-01-31T14:15:41Z")

</div>

It is there, pls look at the beginning of the post. Still not working.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 1, 2020, 4:40am UTC](https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251/4 "2020-02-01T04:40:02Z")

</div>

What gives:

```
mvn dependency:tree

```

?

---

<div class="post-metadata">

### Author: ![franzisk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/franzisk/32/61527_2.png) [@franzisk](https://discuss.elastic.co/u/franzisk)
#### Post date: [February 3, 2020, 10:44am UTC](https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251/5 "2020-02-03T10:44:10Z")

</div>

That gives:

```
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ m2g-superlog-api ---
[INFO] com.m2g.superlog:m2g-superlog-api:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.2.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.2.4.RELEASE:compile
[INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.25:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.2.4.RELEASE:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.10.2:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.10.2:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.10.2:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.10.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.2.4.RELEASE:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.30:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.30:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.30:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-validation:jar:2.2.4.RELEASE:compile
[INFO] | | +- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] | | \- org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:compile
[INFO] | | \- org.jboss.logging:jboss-logging:jar:3.4.1.Final:compile
[INFO] | +- org.springframework:spring-web:jar:5.2.3.RELEASE:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.2.3.RELEASE:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:5.2.3.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.2.3.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.2.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.2.4.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.2.4.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.3:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.2:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:test
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.1:test
[INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.5.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.5.2:test
[INFO] | | | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | | \- org.junit.platform:junit-platform-commons:jar:1.5.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.5.2:test
[INFO] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.5.2:test
[INFO] | | \- org.junit.platform:junit-platform-engine:jar:1.5.2:test
[INFO] | +- org.mockito:mockito-junit-jupiter:jar:3.1.0:test
[INFO] | +- org.assertj:assertj-core:jar:3.13.2:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.1:test
[INFO] | +- org.mockito:mockito-core:jar:3.1.0:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.10.6:compile
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.10.6:test
[INFO] | | \- org.objenesis:objenesis:jar:2.6:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:5.2.3.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:5.2.3.RELEASE:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.6.3:test
[INFO] +- org.springframework.boot:spring-boot-starter-data-elasticsearch:jar:2.2.4.RELEASE:compile
[INFO] | \- org.springframework.data:spring-data-elasticsearch:jar:3.2.4.RELEASE:compile
[INFO] | +- org.springframework:spring-tx:jar:5.2.3.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:2.2.4.RELEASE:compile
[INFO] | +- joda-time:joda-time:jar:2.10.5:compile
[INFO] | +- org.elasticsearch.client:transport:jar:7.5.2:compile
[INFO] | | +- org.elasticsearch:elasticsearch:jar:7.5.2:compile
[INFO] | | | +- org.elasticsearch:elasticsearch-core:jar:7.5.2:compile
[INFO] | | | +- org.elasticsearch:elasticsearch-secure-sm:jar:7.5.2:compile
[INFO] | | | +- org.elasticsearch:elasticsearch-x-content:jar:7.5.2:compile
[INFO] | | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.10.2:compile
[INFO] | | | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.10.2:compile
[INFO] | | | | \- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.10.2:compile
[INFO] | | | +- org.elasticsearch:elasticsearch-geo:jar:7.5.2:compile
[INFO] | | | +- org.apache.lucene:lucene-core:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-analyzers-common:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-backward-codecs:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-grouping:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-highlighter:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-join:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-memory:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-misc:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-queries:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-queryparser:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-sandbox:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-spatial:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-spatial-extras:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-spatial3d:jar:8.3.0:compile
[INFO] | | | +- org.apache.lucene:lucene-suggest:jar:8.3.0:compile
[INFO] | | | +- org.elasticsearch:elasticsearch-cli:jar:7.5.2:compile
[INFO] | | | | \- net.sf.jopt-simple:jopt-simple:jar:5.0.2:compile
[INFO] | | | +- com.carrotsearch:hppc:jar:0.8.1:compile
[INFO] | | | +- com.tdunning:t-digest:jar:3.2:compile
[INFO] | | | \- org.elasticsearch:jna:jar:4.5.1:compile
[INFO] | | +- org.elasticsearch.plugin:reindex-client:jar:7.5.2:compile
[INFO] | | | \- org.elasticsearch:elasticsearch-ssl-config:jar:7.5.2:compile
[INFO] | | +- org.elasticsearch.plugin:lang-mustache-client:jar:7.5.2:compile
[INFO] | | | \- com.github.spullara.mustache.java:compiler:jar:0.9.6:compile
[INFO] | | +- org.elasticsearch.plugin:percolator-client:jar:7.5.2:compile
[INFO] | | +- org.elasticsearch.plugin:parent-join-client:jar:7.5.2:compile
[INFO] | | \- org.elasticsearch.plugin:rank-eval-client:jar:7.5.2:compile
[INFO] | +- org.elasticsearch.plugin:transport-netty4-client:jar:7.5.2:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.1.45.Final:compile
[INFO] | | +- io.netty:netty-codec:jar:4.1.45.Final:compile
[INFO] | | +- io.netty:netty-codec-http:jar:4.1.45.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.45.Final:compile
[INFO] | | +- io.netty:netty-handler:jar:4.1.45.Final:compile
[INFO] | | +- io.netty:netty-resolver:jar:4.1.45.Final:compile
[INFO] | | \- io.netty:netty-transport:jar:4.1.45.Final:compile
[INFO] | +- org.elasticsearch.client:elasticsearch-rest-high-level-client:jar:7.5.2:compile
[INFO] | | +- org.elasticsearch.client:elasticsearch-rest-client:jar:7.5.2:compile
[INFO] | | | +- org.apache.httpcomponents:httpasyncclient:jar:4.1.4:compile
[INFO] | | | \- org.apache.httpcomponents:httpcore-nio:jar:4.4.13:compile
[INFO] | | +- org.elasticsearch.plugin:mapper-extras-client:jar:7.5.2:compile
[INFO] | | \- org.elasticsearch.plugin:aggs-matrix-stats-client:jar:7.5.2:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.10.2:compile
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:2.2.4.RELEASE:runtime (optional)
[INFO] | +- org.springframework.boot:spring-boot:jar:2.2.4.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-autoconfigure:jar:2.2.4.RELEASE:compile
[INFO] +- net.bull.javamelody:javamelody-spring-boot-starter:jar:1.80.0:compile
[INFO] | +- net.bull.javamelody:javamelody-core:jar:1.80.0:compile
[INFO] | | \- org.jrobin:jrobin:jar:1.5.9:compile
[INFO] | \- org.springframework.boot:spring-boot-starter-aop:jar:2.2.4.RELEASE:compile
[INFO] | \- org.aspectj:aspectjweaver:jar:1.9.5:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.2.4.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.2.4.RELEASE:compile
[INFO] | | \- org.springframework.boot:spring-boot-actuator:jar:2.2.4.RELEASE:compile
[INFO] | \- io.micrometer:micrometer-core:jar:1.3.2:compile
[INFO] | +- org.hdrhistogram:HdrHistogram:jar:2.1.11:compile
[INFO] | \- org.latencyutils:LatencyUtils:jar:2.0.3:compile
[INFO] +- io.springfox:springfox-swagger2:jar:2.9.2:compile
[INFO] | +- io.swagger:swagger-annotations:jar:1.5.20:compile
[INFO] | +- io.swagger:swagger-models:jar:1.5.20:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.2:compile
[INFO] | +- io.springfox:springfox-spi:jar:2.9.2:compile
[INFO] | | \- io.springfox:springfox-core:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-schema:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-swagger-common:jar:2.9.2:compile
[INFO] | +- io.springfox:springfox-spring-web:jar:2.9.2:compile
[INFO] | +- com.google.guava:guava:jar:20.0:compile
[INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] | +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] | +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] | \- org.mapstruct:mapstruct:jar:1.2.0.Final:compile
[INFO] +- io.springfox:springfox-swagger-ui:jar:2.9.2:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.12.1:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.12.1:compile
[INFO] +- org.apache.logging.log4j:log4j-web:jar:2.12.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-log4j2:jar:2.2.4.RELEASE:compile
[INFO] | +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.12.1:compile
[INFO] | +- org.apache.logging.log4j:log4j-jul:jar:2.12.1:compile
[INFO] | \- org.slf4j:jul-to-slf4j:jar:1.7.30:compile
[INFO] +- com.lmax:disruptor:jar:3.3.6:compile
[INFO] \- org.apache.httpcomponents:httpclient:jar:4.5.10:compile
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] \- commons-codec:commons-codec:jar:1.13:compile

```

Thanks for helping.

At this point I gave up using repository actions and I am using HTTP requests make ES operations, but if I could use repository actions that would be great.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 7, 2020, 8:47am UTC](https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251/6 "2020-02-07T08:47:51Z")

</div>

My guess is that it's an old spring data version which was not compatible with ES 7.5.  
I've seen recently on spring web site that they just released a new version of spring data elasticsearch which is compatible with 7.5. May be you need to upgrade that module?

---

<div class="post-metadata">

### Author: ![franzisk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/franzisk/32/61527_2.png) [@franzisk](https://discuss.elastic.co/u/franzisk)
#### Post date: [February 7, 2020, 10:27am UTC](https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251/7 "2020-02-07T10:27:53Z")

</div>

It's something similar to that, actually I removed the version number and Spring downloaded the 6.8.6 version and everything works now.

Thanks for your feedback

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 6, 2020, 10:28am UTC](https://discuss.elastic.co/t/method-gettotalhits-duplicated-and-not-found-at-the-same-time/217251/8 "2020-03-06T10:28:06Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
